如果将图片设置为浮动,在一个DIV里一张左浮动,一张右浮动。并且向设置图片距离边框有一定距离,应该怎么写呢?求助啊!!各位大神们。关于这部分的代码如下:
.contentc{position:relative;height:auto;width:100%;}
.borderleft{float:left;background:url(../images/leftyy.png) repeat-y;height:500px;width:16px;}
.borderright{float:right;background:url(../images/rightyy.png) repeat-y;height:500px;width:16px;}
<div class="contentc">
<div class="borderleft"></div>
<div class="borderright"></div>
</div>
<html>
<style>
.ab{width:300px;
height:200px;
background:#09f;
padding:10px;
}
.ab-1{width:100px;
height:100px;
background:#f96;
margin:10px;
float:left;
}
.ab-2{width:100px;
height:100px;
background:#f9f;
margin:10px;
float:right;
}
</style>
<body>
<div class="ab">
<div class="ab-1"><img src="smiley.gif" style="width:100px;height:100px"/></div>
<div class="ab-2"></div>
</div>
</body>
</html>
可以用margin 设置 外边距
.borderleft{float:left;background:url(../images/leftyy.png) repeat-y;height:500px;width:16px;margin-left:10px;}
.borderright{float:right;background:url(../images/rightyy.png) repeat-y;height:500px;width:16px;margin-right:10px;}