今天做了一個項目,效果圖內頁的產品圖片都是帶圓角的,於是前端的做了圓角的效果,div+css是這樣的,首先div布局是:
<div class="tiandi_item" onclick="javascript:location.href='#'">
<div class="tiandi_item_img"><img src="images/tiandi_04.jpg" /></div>
<div class="tiandi_item_text ellipsis">六一兒童節互動六一兒童節互動六一兒童節互動</div>
(css文件里)加入如下樣式:
.tiandi_item{ width:160px; height:145px; background-color:#faecb2; border-radius:12px; -webkit-border-radius:12px; -moz-border-radius:12px; text-align:center; padding-top:5px; line-height:30px; overflow:hidden; float:left; margin:0 50px 10px 0; cursor:pointer;}
.tiandi_item_img{ width:154px; height:112px; overflow:hidden;border-radius:12px; -webkit-border-radius:12px; -moz-border-radius:12px;}
.tiandi_item_img img{ width:100%; display: block; margin-bottom: 7px; border: 1px solid #ffd300; border-radius:12px; -webkit-border-radius:12px; -moz-border-radius:12px;}
控制圓角主要是border-radius:12px; -webkit-border-radius:12px; -moz-border-radius:12px;,后面的主要是兼容webkit內核和moz的瀏覽器,.tiandi_item_img img也要加radius是因為圖片大小不同,有的圖片上邊有圓角,下邊沒有圓角