简体   繁体   中英

Line up Text to top of Image in divs

I'd like to line up the text to the top of the images in my divs.

Currently the title: Webinar, Blog, etc are sitting below the top of the squares. I have a style in there: vertical-align: top; but it's not aligning to the top of the square.

See my Fiddle - http://jsfiddle.net/huskydawgs/e9pZr/ HTML

<div id="wrapper-resources">
        <div id="resources_row">
            <div class="resources_cell1">
                <div class="resources_lt">
                    <img height="76" src="https://cdn1.iconfinder.com/data/icons/softwaredemo/PNG/256x256/Box_Red.png" width="76" /></div>
                <div class="resources_rt">
                    <p><strong>Webinar</strong></p>
                </div>
            </div>
            <div class="resources_cell2">
                <div class="resources_lt">
                    <img height="76" src="https://cdn1.iconfinder.com/data/icons/softwaredemo/PNG/256x256/Box_Red.png" width="76" /></div>
                <div class="resources_rt">
                    <p><strong>Article</strong></p>
                </div>
            </div>
            <div class="resources_cell3">
                <div class="resources_lt">
                    <img height="76" src="https://cdn1.iconfinder.com/data/icons/softwaredemo/PNG/256x256/Box_Red.png" width="76" /></div>
                <div class="resources_rt">
                    <p><strong>Blog</strong></p>
                </div>
            </div>
            <div class="resources_cell4">
                <div class="resources_lt">
                    <img height="76" src="https://cdn1.iconfinder.com/data/icons/softwaredemo/PNG/256x256/Box_Red.png" width="76" /></div>
                <div class="resources_rt">
                    <p><strong>Market</strong></p>
                </div>
            </div>
        </div>
    </div>

CSS

#wrapper-resources {
position:relative;
width:100%;
border: none;
margin: 50px 0 0 0;

}

#resources_row {
height:100%;
white-space:nowrap;
}

.resources_cell1, .resources_cell2, .resources_cell3, .resources_cell4 {
height:100%;
width:25%;
display:inline-block;
white-space:normal;
}

.resources_lt {
height:100%;
width:33%;
display:inline-block;
white-space:normal;
margin-right: 20px;
vertical-align: top;
}

.resources_rt {
height:100%;
width:50%;
display:inline-block;
white-space:normal;
vertical-align: top;
}

/* Fonts */

#wrapper-resources p {
color: #666666;
font-family: 'SegoeRegular', Helvetica, Arial, sans-serif;
font-size: .9em;
line-height: 1.6em;

}

you need to reset margin to 0 for your <p> http://jsfiddle.net/e9pZr/3/

it has by default margin:1em 0; see http://reference.sitepoint.com/css/collapsingmargins for more explanations.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM