center

Position center of div tag, which width is unknown advanced

一曲冷凌霜 提交于 2020-01-03 03:41:07
问题 I have div with no fixed with. I want this div position in the center of screen. I know how to make this with jquery, but with pure css, I did not find any solution. How do you make this happen with pure css? 回答1: Assuming you want to shrink-wrap the contents of the div (otherwise centring it is a pointless exercise as its width will be the width of the container): Set display: inline-block; on the div to make it shrink-wrap Set text-align: center; on the div's parent element to centre the

center a div (absolute position and width)

流过昼夜 提交于 2020-01-03 02:54:13
问题 i use below css to center my div with absolute position: #mydiv { position:absolute; top: 50%; left: 50%; width: 121px; height: 121px; margin-top: -60.5px; /*set to a negative number 1/2 of your height*/ margin-left: -60.5px; /*set to a negative number 1/2 of your width*/ } It works like magic. But as you can notice, it has fixed width and height. Now i have to use this same css but for my div which has no fixed width and height, as it uses responsive layouts. I just want to know is there any

Evenly spaced and justified horizontal list menu

ⅰ亾dé卋堺 提交于 2020-01-02 05:38:09
问题 I searched and found no solution to spacing out a series of lis for a list style menu. I realized CSS alone can't do it so I added some javascript (jQuery). I didn't want the same widths for each LI, I wanted even padding with no leftover space. If anyone can take this concept and simplify my awful javascript or offer alternatives please do so. See example here: http://www.valweb.com/menuTest/ 回答1: As CSS alone can do so but old IEs can't, why not use display: table; (and table-cell) as a

How to figure out on which screen a JDialog is shown

会有一股神秘感。 提交于 2020-01-01 09:32:10
问题 I have a really big application which has multiple dialogs. My task is to make sure that a dialog, which is not completely visible (because the user pulled it out of the visible screen area) is moved back to the center of the screen. That's no problem when I'm dealing with one screen only. It works just fine ... however, most users of this application have two screens on their desktop ... When I try to figure out on which screen the dialog is shown and center it on that specific screen, ...

Center vertically a unknown height text in a unknown height div

烈酒焚心 提交于 2020-01-01 08:47:49
问题 I know this is a common issue, and I've already asked a similar one. But I could not find the solution this time. I am trying to vertically center a text which can have different height in a DIV which can have different height. And I am trying to solve this only with CSS, without touching the HTML. Example : http://jsfiddle.net/F8TtE/ <div id="test"> <div id="sumup"> <h1 class="titre">Title</h1> <div id="date">hello guys</div> </div> </div> My goal is to have the text centered vertically and

CSS Responsive Center Div

穿精又带淫゛_ 提交于 2020-01-01 00:43:55
问题 I would like to center some div which has background image. There is problem with response of this div, because if I set width on 80% and height on 80% the bg-image is not on center. I tried everything, but the picture can't just stand on center and if the browser is smaller or bigger this is very big problem. So if you look at the picture I want to make this white block responsive. There is a little of css which I've already written, but for now is non-responsive: top: 20%; left: 30%;

Centering a background image in Android

假装没事ソ 提交于 2019-12-31 08:57:29
问题 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. 回答1: 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. 回答2: Question is old and answer has one

How do I center a <div>? [duplicate]

和自甴很熟 提交于 2019-12-30 17:45:22
问题 This question already has answers here : Closed 8 years ago . Possible Duplicate: How to center DIV in DIV? I want to center a <div> (I'm new to HTML5 and the <center> tag is no more), and by all means avoid using a table. This is what I've got as CSS for the <div> in question so far: #roundedcorner { -moz-border-radius: 15px; border-radius: 15px; background-image: url(file:///Macintosh%20HD/Users/julesmazur/Desktop/TAN3.0/Photos/bodydivbg.png); width: 960px; left: 50%; font-family: Ubuntu; }

jQuery: Animate Margins to Auto?

僤鯓⒐⒋嵵緔 提交于 2019-12-29 06:18:33
问题 I'm trying to animate an image so that it centers itself. Here's the code I'd like to use: $('#myImage').animate({'margin-right': 'auto'}); But when I do that, it's ignored and doesn't change the margin. Is there a way to animate a margin to auto, or otherwise center an image? Thanks! 回答1: As 'auto' isn't a number, jQuery cannot animate it. If you are okay with taking the image out of the flow of the document, you can set position to absolute or fixed and try: $('#myImage').animate({'left':

jQuery: Animate Margins to Auto?

家住魔仙堡 提交于 2019-12-29 06:18:08
问题 I'm trying to animate an image so that it centers itself. Here's the code I'd like to use: $('#myImage').animate({'margin-right': 'auto'}); But when I do that, it's ignored and doesn't change the margin. Is there a way to animate a margin to auto, or otherwise center an image? Thanks! 回答1: As 'auto' isn't a number, jQuery cannot animate it. If you are okay with taking the image out of the flow of the document, you can set position to absolute or fixed and try: $('#myImage').animate({'left':