0

在我的网站上,我允许用户使用名称和图片发表评论。我注意到一个问题,当有人使用 html 代码在评论中发布更大的图片时,它会用完评论框。所以我想要的只是东西应该留在评论框中。无论他们发布多大的图片。我已经在下面发布了所有详细信息,请帮助谢谢:|

在此处输入图像描述

我的html

<div class="mycomment">
        <div id="postpic">
            <img id="profile_pic" width="50px" height="150px" src="image/user/1.gif" class="">
        </div>
        <div class="mycommentpost">                     
            <a class="postername" href="profile.php?userID=1">Deepak Kumar: </a><br>
            <img src="http://i00.i.aliimg.com/wsphoto/v0/789295022/-font-b-Easter-b-font-day-font-b-Bunny-b-font-ears.jpg" width="650" height="350" alt="">
        </div>
</div>

我的CSS:

.mycomment {
font-weight: normal;
color: #000000;
border: 2px solid #DEDEDE;
letter-spacing: 1pt;
font-family: arial, helvetica, sans-serif;
float: left;
width: 550px;
margin: 20px 0;
}

#postpic {
float: left;
width: 70px;
}

.mycommentpost {
font-weight: normal;
color: #000000;
letter-spacing: 1pt;
width: 480px;
float: right;
}

.postername {
color: #580000;
font-weight: bold;
font-size: 1em;
text-decoration: none;
}

这里的评论只是一张图片:

<img src="http://i00.i.aliimg.com/wsphoto/v0/789295022/-font-b-Easter-b-font-day-font-b-Bunny-b-font-ears.jpg" width="650" height="350" alt="">

解决:通过添加这个->

.mycommentpost > img{
    max-height: XXXpx !important;
    max-width: XXXpx !important;
}
4

3 回答 3

2

添加到您的 CSS

.mycommentpost > img{
    max-height: XXXpx !important;
    max-width: XXXpx !important;
}

这样,您将限制添加图像的最大尺寸..

于 2013-04-01T06:24:54.720 回答
0

试试这个

<div class="mycomment">
    <div id="postpic">
        <img id="profile_pic" width="50px" height="150px" src="image/user/1.gif" class="">
    </div>
    <div class="mycommentpost">                     
        <a class="postername" href="profile.php?userID=1">Deepak Kumar: </a><br>
        <img src="http://i00.i.aliimg.com/wsphoto/v0/789295022/-font-b-Easter-b-font-day-font-b-Bunny-b-font-ears.jpg" width="650" height="350" alt="">
    </div>

.mycommentpost {
font-weight: normal;
color: #000000;
letter-spacing: 1pt;
width: 480px;
float: left;
}
.mycommentpost img{
 width :450px;   
}
于 2013-04-01T06:24:53.907 回答
0

无论他们使用此 css 上传什么大小的图像,都将图像设置为 mycommentpost div 中的默认大小。

> .mycommentpost img{
>      border: 1px solid #DEDEDE;
>     padding: 10px;
>     width: 130px; }
于 2013-04-01T06:30:20.303 回答