pai*_*lee 10
根据盒子模型,填充在内容和边界之间.您应该能够像这样设置图像的样式:
.img-btn {
background: #FFF; // inner border color
padding: 2px; // inner border width
border: 2px solid #[yourgreen]; // outer border
}
Run Code Online (Sandbox Code Playgroud)
div
即使对于纯CSS按钮,也不需要任何额外的s来完成此任务.以下样式适用于图像为背景图像的情况:
.img-btn {
background: #FFF url('your.img') no-repeat;
padding: 2px;
border: 2px solid #[yourgreen];
width: [image width];
height: [image height];
background-position: center center;
}
Run Code Online (Sandbox Code Playgroud)
这是如上所述的双边界演示.
你不需要两个<divs>
和一个<a>
按钮.你可以用一个单独做<a>
.对于图像和按钮,您可以使用它box-shadow
来执行外边框.background-images
在<img>
元素中居中.
演示:http://jsfiddle.net/ThinkingStiff/bNmzB/
输出:
HTML:
<a id="add" href="#">Add To Cart</a>
<img id="facebook" class="icon" />
<img id="twitter" class="icon" />
<img id="email" class="icon" />
Run Code Online (Sandbox Code Playgroud)
CSS:
#add {
background-color: #9bc9c7;
border: 1px solid white;
box-shadow: 0 0 0 2px #9bc9c7;
color: white;
display: inline-block;
font: normal 13px/25px Helvetica, Arial, Sans Serif;
height: 25px;
margin-right: 6px;
text-align: center;
text-decoration: none;
text-transform: uppercase;
width: 120px;
vertical-align: top;
}
#add:hover {
background-color: #eabeb2;
box-shadow: 0 0 0 2px #eabeb2;
}
.icon {
background-color: rgb( 155, 201, 199 );
border: 1px solid white;
box-shadow: 0 0 0 2px rgb( 155, 201, 199 );
height: 25px;
margin-right: 3px;
width: 25px;
}
Run Code Online (Sandbox Code Playgroud)