Centering an tag
Try margin: auto; <hr style=”width:100px; margin: auto;” />
Try margin: auto; <hr style=”width:100px; margin: auto;” />
Flexbox The most efficient solution to your problem is probably flexbox, as flex items are not confined to individual tracks (columns/rows) like grid items. .grid { display: flex; flex-wrap: wrap; margin-bottom: 1em; } .item { flex: 1 0 100px; background: #eee; text-align: center; border: 1px dashed gray; box-sizing: border-box; } <div class=”grid”> <div class=”item”>Item 1</div> … Read more
You dont need absolute positioning Use p { text-align: center; line-height: 100px; } And adjust at will… If text exceeds width and goes more than one line In that case the adjust you can do is to include the display property in your rules as follows; (I added a background for a better view of … Read more
You can’t. If it were centered within the parent box, then the float would overlap the content at some point, which would be defeating the point of the float. There are two approaches you can use here. If you know the width of the float, you can apply an equal negative right margin. Otherwise, you … Read more
You need to consider flex-shrink. As you can read here: The flex-shrink CSS property specifies the flex shrink factor of a flex item. Flex items will shrink to fill the container according to the flex-shrink number, when the default size of flex items is larger than the flex container. body { margin: 0; } * … Read more
You were close! It can be done with CSS alone: Use position: fixed instead of position: absolute. Fixed refers to the viewport, while absolute refers to the document. Read all about it!
body { width:80%; margin-left:auto; margin-right:auto; } This will work on most browsers, including IE.
Try something like this… <div id=”wrapper” style=”width:100%; text-align:center”> <img id=”yourimage”/> </div>
Edit November 2015: In Foundation 6 check out Typography Helpers Edit April 2014: In Foundation 5 check out Utility classes. Original answer: Use the text-center class. <div class=”row”> <div class=”twelve columns text-center”><br /> <img src=”https://stackoverflow.com/questions/12079049/img_06.jpeg” alt=”slide image”> </div> </div> Source: https://github.com/zurb/foundation/pull/224
Pushing the element left by 50% of its width and then translating it horizontally by 50% has worked for me. .element { position: absolute; left: 50%; transform: translateX(-50%); } I found the concept in the following link, and then I translated to fit my horizontal align needs: https://gist.github.com/colintoh/62c78414443e758c9991#file-douchebag-vertical-align-css