Home Upgrade Search Memberlist Extras Hacker Tools Award Goals Help Wiki Contact

Div doesn't want to center?

I tired a bunch of things and for some reason it doesnt want to center in the page

Code
<div class="element be-hoverlay style1-hover  style3-title" style="margin:auto;" align="center">
                                                                <div class="element-inner">
                                                                    <a class="" title="">
                                                                        <div class="flip-wrap">
                                                                            <div class="flip-img-wrap zoom-in-effect"><img src="upload/carlos.jpg" alt /></div>
                                                                        </div>
                                                                        <div class="thumb-overlay">
                                                                            <div class="thumb-bg" style="background-color:rgba(216,8,8,0.75); ">
                                                                                <div class="thumb-title-wrap ">
                                                                                    <div class="thumb-title be-animate animated animation-trigger" data-animation-type="none" style="color: #ffffff;">Driveways</div>
                                                                                  
                                                                                </div>
                                                                            </div>
                                                                        </div>
                                                                    </a>
                                                                </div>
[Image: rVdyS6y.png]
align="center" only centers the content inside of the DIV.

Here's a website you'll find useful, http://howtocenterincss.com/
You could use Bootstrap. Then you will center a div adding a class name to it: "center-block".
[Image: TrJCrgs.jpg]
I would suggest not using Bootstrap if you're just starting out. I've saw people use it when they are new and now they can't not use it.
You can't really use margin: 0 auto; unless you give it an implicit width.

Dostoevsky(const Dostoevsky&) = delete;
[Image: T4BXHDP.png]
Here's what you have to do to center anything.

For a DIV (or any block element)
Step 1- Give it a specific width, Example- width:500px;
Step 2- margin:auto auto;

For an Inline-block element
Step 1- position:absolution
Step 2- left:0;
Step 3- right:0;
Step 4- margin:auto auto;

Note- This way you can always center any element, if it doesn't work on some element then use display:block/inline-block on that element first.
If you want to center a div, without specifying the width, you can try with:

Code
#element {
    display: table;
    margin: 0 auto;
}

//jsfiddle.net/segk03hs


Possibly Related Threads...
Thread / Author Replies Views Last Post
by EffexionApr 15, 2021 05:12 AM 10 278 Apr 15, 2021 05:12 AM
Last Post: Goku
by CarrotDec 24, 2020 12:16 PM 0 244 Dec 24, 2020 12:16 PM
Last Post: Carrot
by craigOwnsYouOct 31, 2019 01:13 PM 0 103 Oct 31, 2019 01:13 PM
Last Post: craigOwnsYou