Robin Timman
Robin Timman

Reputation: 519

Css centering boxes percentages workings

How do I remove the remaining space on the right: HTML code:

    <div class="wrapper">
        <a href="#"><h1>Title 1</h1></a>
        <a href="#"><h1>Title 1</h1></a>
        <a href="#"><h1>Title 1</h1></a>
    </div>

CSS code:

.wrapper {
height:                                                         450px;
margin:                                                         50px;
border-radius:                                                  30px;
overflow:                                                       hidden;
background-color:                                               #F00;
border:                                                         1px solid #000;
display:block;
}
.wrapper a {
    width:                                                      33.3%;
    height:                                                     100%;
    background-color:                                           #444;
    margin:0 auto;
    float:                                                      left;
    color:                                                      #fff;
    text-decoration:                                            none;
    display:inline-block;
}
.wrapper a:nth-child(2) {
    background-color:                                           #333;
}
.wrapper a h1 {
    width:                                                      100%;
    height:                                                     70px;
    text-align:                                                 center;
    position:                                                   relative;
    bottom:                                                     0;
    text-shadow:                                                1px 1px #000;
}

http://jsfiddle.net/6bXQ9/

the 3 blocks must be 33,3 % but the rest(0,1%) wont be filled, and ive i use 33,4% there will get 1 block lost when the page is smaller

what should i use? Thanks! and sorry for my bad english

Upvotes: 1

Views: 58

Answers (2)

Prakash Chennupati
Prakash Chennupati

Reputation: 3226

Is this what you want? http://jsfiddle.net/6bXQ9/5/

width: 33.33%;

Making Width: 33.33% solves your problem.

Upvotes: 1

herinkc
herinkc

Reputation: 346

width: 33.33% does the magic trick.

Upvotes: 1

Related Questions