如何调整这些跨度的大小,使图片不会超出它们?

时间:2011-05-05 11:14:36

标签: html css

jsFiddle

在这个HTML / CSS中,我试图创建一些容器,它们可以容纳一些文本,一个个人资料图片(可以有不同的大小)和名称。

CSS

#fb_status_10150163932662967{
    background:url(http://www.pixel2life.com/twodded/staff/stu/Tutorials/BrickTexture/bricks_zigzag_texture_6190218.JPG) #C0DEED; padding:20px;
}
#fb_status_10150163932662967 p{
    background:#fff;
    padding:10px 12px 10px 12px;
    margin:0;
    min-height:48px;
    color:#000;
    font-size:18px !important;
    line-height:22px;
    -moz-border-radius:5px;
    -webkit-border-radius:5px
}
#fb_status_10150163932662967 p span.metadata{
    display:block;
    width:100%;
    clear:both;
    margin-top:8px;
    padding-top:12px;
    height:40px;
    border-top:1px solid #fff;
    border-top:1px solid #e6e6e6
}
#fb_status_10150163932662967 p span.metadata span.author{
    line-height:19px
}
#fb_status_10150163932662967 p span.metadata span.author img{
    float:left;
    margin:0 7px 0 0px;
}
#fb_status_10150163932662967 p a {
    color: #0084B4;
    text-decoration:none;
}
#fb_status_10150163932662967 p a:hover{
    text-decoration:underline
}
#fb_status_10150163932662967 p span.embedly_timestamp{
    font-size:12px;
    display:block
}

HTML

<div id="fb_status_10150163932662967" class="fb_status">
    <p>
        text1
        <span class="metadata">
            <span class="author">
                <img src="https://fbcdn-profile-a.akamaihd.net/hprofile-ak-snc4/48898_565722966_3090_t.jpg">
                <strong>
                    Ben
                </strong>
                <br>
            </span>
        </span>
    </p>
    <br>
    <p>
        text2
        <span class="metadata">
            <span class="author">
                <img src="https://fbcdn-profile-a.akamaihd.net/hprofile-ak-snc4/187486_564261187_2838929_t.jpg">
                <strong>
                    Kirsty
               </strong>
                <br>
            </span>
        </span>
    </p>
    <br>
    <p>
        text3
        <span class="metadata">
            <span class="author">
                <img src="https://fbcdn-profile-a.akamaihd.net/hprofile-ak-snc4/48898_565722966_3090_t.jpg">
                <strong>
                    Ben
                </strong>
                <br>
            </span>
        </span>
    </p>
</div>

正如您在jsFiddle中看到的那样,个人资料图片会延伸到容器之外。我怎样才能将它们完全包含在容器中?

3 个答案:

答案 0 :(得分:2)

@ben;只需overflow:hidden代码中的p

检查此http://jsfiddle.net/sandeep/Tu5Y5/7/

答案 1 :(得分:0)

增加身高

#fb_status_10150163932662967 p span.metadata {
    border-top: 1px solid #E6E6E6;
    clear: both;
    display: block;
    height: 60px;
    margin-top: 8px;
    padding-top: 12px;
    width: 100%;
}

或写

overflow: hidden; in #fb_status_10150163932662967 p { }

答案 2 :(得分:0)

尝试添加:

#fb_status_10150163932662967 p { overflow: auto; }

在这里查看:

http://jsfiddle.net/ahmad/5p3fx/2/