I want to float a div
to center. Is it possible? text-align: center
is not working in IE.
相关问题
- Views base64 encoded blob in HTML with PHP
- Is there a way to play audio on a mobile browser w
- HTML form is not sending $_POST values
- implementing html5 drag and drop photos with knock
- Adding a timeout to a render function in ReactJS
Float the div in the background to the max width, set a div inside that that's not transparent and center it using margin auto.
this works nicely
This resizes nicely with adaptive layouts also..
CSS example would be:
floating divs to center "works" with the combination of display:inline-block and text-align:center.
Try changing width of the outer div by resizing the window of this jsfiddle
and the css:
This worked for me..
No, it isn't.
You can either have content bubble up to the right of an element (
float: left
) or to the left of an element (float: right
), there is no provision for having content bubble up on both sides.One of my websites involves a div whose size is variable and you won't know it ahead of time. it is an outer div with 2 nested divs, the outer div is the same width as the first nested div, which is the content, and the second nested div right below the content is the caption, which must be centered. Because the width is not known, I use jQuery to adjust accordingly.
so my html is this
and then I center the captions in jQuery like this