如何用div+css压缩图片

html-css011

如何用div+css压缩图片,第1张

把图片放置到一个DIV里,设置图片的高和宽都是 100%,然后你就控制DIV的宽和高来缩放图片的大小可以了。

代码如下:

<div style="width:40pxheight:30px"><img src="d_r2_c4.jpg" style="width:100%height:100%"/></div>

谢谢采纳O(∩_∩)O~!!!

你有几个单词不认真写错了

li{list-style-type: none}

#c3{margin-top:33px clear:both}

#c3 .c3{ float:left width:300px overflow:hidden}

#c3 .c3-center{margin:auto 50px}

#c3 .c3 .header{ height:34px overflow:hidden}

#c3 .c3 .header .title{ line-height:24px font:"微软雅黑",Arial 18px color:#333 float:left width:220px padding-bottom:7px border-bottom:#fd8000 2px solid}

#c3 .c3 .header .title span{ color:#fd8000}

#c3 .c3 .header .more{float:left width:80px overflow:hidden height:32px border-bottom:#353748 1px solid}

#c3 .c3 .header .more a img{ border:0 float:right display:block margin-top:4px}

#c3 .c3 .content{margin:44px 0px 25px 0px}

#c3 .c3 .content p{text-indent:28px font-size:14px line-height:24px margin:0px padding-top:25px}

#c3 .c3 .content .abc{font-size:14px line-height:30px color:#cacaca border-bottom:2px #cacaca dotted padding-top:2pxmargin:0padding-left: 0}

#c3 .c3 .content .abc .abc1{color:#cacaca line-height:25px}

#c3 .c3 .content .date{font-size:14px line-height:34px color:#cacaca}

#c3 .c3 .content .date .date1{line-height:25px margin-top:3px}

sibhuang知道问题出在哪里,不过CSS写错了。问题就在于c类的块使用了浮动float,使得b类块被“压缩”(dreamweaver里面可以看到)

html代码如 sibhuang 所写,在b中最后一个c块增加一个清除浮动的块,定义为clear类

CSS为

.clear { clear:both}