1

我无法使图像浮动到文本的左侧。能否请你帮忙?我也可以在 CSS 中写 width="200" height="200" 吗?如果可能,怎么做?谢谢你的帮助。

Html code

        <div class="content">
        <img src="img1.jpg" class="bw" width="200" height="200" alt="king">
        Content is very important bla bla bla....Content is very important bla bla bla....Content is very important bla bla bla....Content is very important bla bla bla....Content is very important bla bla bla....Content is very important bla bla bla....Content is very important bla bla bla....Content is very important bla bla bla....Content is very important bla bla bla....Content is very important bla bla bla....
        </div>


CSS
     div.content {
         width:80%;
         padding-top: 2pc;
         padding-left: 5pc;
         text-align:left;
         font: 10pt Helvetica,"Helvetica neue", Arial, sans-serif;
         margin-left: 100px;
         margin-right: 300px;
         color: #000000 }

     div.img.bw {
         float:left;
         margin:4px; }
4

2 回答 2

2

最大的问题是您的选择器在您的图像上是错误的。

它应该是:

div img.bw {
float: left;
margin: 4px; 
}

现在 css 正在寻找一个带有“img”类的 div。

于 2012-04-17T17:46:22.980 回答
2

div.img.bw是不正确的。您应该将其定义为div img.bw. 您需要定位和元素是 a image,其中类bw是 a 的元素内div。这是什么div img.bw目标。还要定义高度和宽度使用:

 div img.bw {
  float:left;
  margin:4px; 
  width:200px;
  height:200px;
}
于 2012-04-17T17:46:25.260 回答