2014-03-26 34 views
-1

我使用border-image标记在css中创建自定义边框。 我使用的背景颜色与边框颜色相同。但它不能填满整个身高。自定义边框css和背景图像

<!DOCTYPE html> 
<html> 
<head> 
<style> 

div{ 
border:15px solid transparent; 
width:250px; 
} 

div p { 
background-color: #74c7a9; 
padding-right: 20px; 
padding-bottom: 20px; 
} 


#round { 
-webkit-border-image:url(border2.png) 30 30 round; /* Safari 5 */ 
-o-border-image:url(border2.png) 30 30 round; /* Opera */ 
border-image:url(border2.png) 30 30 round; 
} 

</style> 
</head> 
<body> 


<div id="round"> 
    <p>Here, the image is tiled (repeated) to fill the area. 
    </p> 
</div> 

</body> 
</html> 

回答

0

你在p背景和DIV边界之间看到的空间是p的保证金(顶部和底部)。

您可以

p { 
    margin: 0px; 
} 

将其关闭,如果你觉得这种方式它变得太小,加

p { 
    padding-top: 20px; 
} 

,或者以其他方式(可能更容易)设置背景在div而不是在p