center

CSS centering tricks [closed]

醉酒当歌 提交于 2019-12-02 22:16:28
As it currently stands, this question is not a good fit for our Q&A format. We expect answers to be supported by facts, references, or expertise, but this question will likely solicit debate, arguments, polling, or extended discussion. If you feel that this question can be improved and possibly reopened, visit the help center for guidance. My favorite equation for centering an xhtml element using only CSS is as follows: display: block; position: absolute; width: _insert width here_; left: 50%; margin-left: _insert width divided by two & multiplied by negative one here_ There's also the simpler

vertical text center in <div>

放肆的年华 提交于 2019-12-02 21:47:55
问题 So i am trying get 2 div-containers which both should contain centered text (Both x- and y-axis). Thanks to Google and stackoverflow, i stumbled over a few workarounds which play with vertical-align etc. But nothing seems to work. #right-menu { position: absolute ; right: 0% ; top: 0% ; height: 100% ; width: 5% ; text-align: center ; background: #ededed ; display: table-cell; vertical-align: middle ; Here is a fiddle: http://jsfiddle.net/7Rgvs/ 回答1: Vertical-align:middle property is not used

Centering a background image in Android

别来无恙 提交于 2019-12-02 19:14:10
I have a background image about 100 x 100 that I want to center in an Android app. Is there a way to do this? I'm thinking it would greatly help with orientation changes for simple apps. You can use BitmapDrawable for the case. Create centered.xml in res/drawable folder: <bitmap xmlns:android="http://schemas.android.com/apk/res/android" android:src="@drawable/your_image" android:gravity="center"/> Then you can use centered drawable as background. Question is old and answer has one big weakness - we have no possibility to change image size, it means it fully depends from drawable we have. While

Centering images in a div vertically

我与影子孤独终老i 提交于 2019-12-02 18:21:08
问题 I have this code for centering vertically the images in a bunch of divs. function centerImages(parent, image) { var parent_height = $(image).parent().height(); var image_height = $(image).height(); var top_margin = (parent_height - image_height)/2; $(image).css( 'margin-top' , top_margin); } centerImages(".clients li", ".clients li img"); .. but it doesn't seem to work. 回答1: Try this instead... function centerImages(image) { var parent_height = $(image).parent().height(); var image_height = $

Simple center a object with css and no hacks

柔情痞子 提交于 2019-12-02 18:07:41
I want to center an object using CSS and no hacks, is this possible and how? I have tried this, but than my p tag is gone. .centered { position: fixed; top: 50%; left: 50%; } CharlieM There's several ways to center an element. But it depends on what your element is and how we choose to display it: If you have {display:inline; } This is simple. You can just use "text-align: center;" to center text, images and divs. If you have {display:block;} This is a bit more difficult. It depends on how your object is positioned. Your object could be relative, absolute, or fixed. If it is relative; then you

CSS: Position loading indicator in the center of the screen

泪湿孤枕 提交于 2019-12-02 18:02:36
How can I position my loading indicator in the center of the screen. Currently I'm using a little placeholder and it seems to work fine. However, when I scroll down, the loading indicator stays right in that predefined position. How can I make it follow the scrolling so that it always sits on top?? #busy { position: absolute; left: 50%; top: 35%; display: none; background: transparent url("../images/loading-big.gif"); z-index: 1000; height: 31px; width: 31px; } #busy-holder { background: transparent; width: 100%; height: 100%; } use position:fixed instead of position:absolute The first one is

How is this put in the center using CSS?

白昼怎懂夜的黑 提交于 2019-12-02 17:47:38
问题 Basically I want to put the div tags below in the center of the page. How is this done in CSS? I am having such a hard time doing it what is the best option!? HTML <div class="tab-selected" id="search">Search</div> <div class="tab-unselected" id="search">Tags</div> <div class="tab-unselected" id="search">Recruiters</div> CSS: .tab-selected { background: #FF00FF; -moz-border-radius: 3px; border-radius: 3px; font: 13px helvetica; color: #FFFFFF; height: 15px; display: inline; } .tab-unselected

Using Markdown, how do I center an image and its caption?

六眼飞鱼酱① 提交于 2019-12-02 17:26:08
I want to end up with: Hello there! <image> This is an image Hi! Where the image and the text This is an image are centered on the page. How do I accomplish this with Markdown? Edit: Note that I'm looking to horizontally center the image and text on the page. You need a block container with a defined height, same value for line-height and image with vertical-align:middle; It should work. Hello there ! <div id="container"> <img /> This is an image </div> Hi ! #container { height:100px; line-height:100px; } #container img { vertical-align:middle; max-height:100%; } I figured that I'd just have

center vertically the content of a div ( not by line-height )

只愿长相守 提交于 2019-12-02 12:53:30
I have a div which I need to center vertically its content: <div draggable="false" id="coffee">Free coffee for all the people who visit my restaurant</div> #coffee { line-height: 235px; width: 300px; } div { position: absolute; overflow: auto; text-align: left; font-size: 23px; color: rgb(26, 66, 108); font-family: roboto, Helvetica; font-style: normal; font-weight: bold; -webkit-transition: none; transition: none; left: 0px; top: 67.125px; height: 234.93749999999997px; opacity: 1; } It works by using line-height, but in the jump line, the phrase is too separated, and I need that it's not

How to horizontally center a DIV

a 夏天 提交于 2019-12-02 11:32:34
问题 How can I horizontally center the DIV with the textbox and button on this URL: http://tinyurl.com/d4lpyh5? Regards, Kevin 回答1: On line 10, you should add a width to the div: Change <div style="margin-left: auto; margin-right: auto;"> to <div style="margin-left: auto; margin-right: auto;width: 700px;"> Edit: If you do it this way, you'll have to change the width of the input elements to a fixed pixel value instead of width: 30%; 回答2: Try this. <center> <input type="text" /> </center> 回答3: