在弯曲框内创建居中弯曲框
我遇到了另一个 CSS 问题,希望能尽快得到解决。我试图简单地拥有一个具有一种背景颜色的弯曲文本框,垂直和水平居中于另一种颜色的另一个弯曲框内。我尝试对一个框使用 border-width 属性,但这仅弯曲了框的外边框,而不是另外弯曲的内边框。我几乎可以正常工作,但它没有垂直居中。这不会太难,但我正在碰壁。这是代码:
<html>
<head>
<style type="text/css">
div#outer {
margin:0 auto;
width:100%;
height:50px;
background-color:#0000FF;
border-radius:5px;
-webkit-border-radius:5px;
text-align:center;
}
#inner{
margin:0 auto;
width:95%;
height:40px;
margin-top:5px;
display:block;
background-color:#ff0000;
border-radius:5px;
-webkit-border-radius:5px;
color:#FFF;
font-size:24px;
font-family:Arial, Helvetica, sans-serif;
font-weight:bold;
line-height:40px;
text-align:center;
}
</style>
</head>
<body>
<div id="outer"><div id="inner">Centered Text goes here</div></div>
</body>
</html>
I got another css issue that I hope can be quickly remedied. I'm trying to simply have a curved box of text with one background color, vertically and horizontally centered inside another curved box of another color. I tried using the border-width attribute for one box, but that only curved the outside border of the box, not the inside border additionally. I almost have it working, but it is not centering vertically. This can't be too hard, but I'm hitting a brick wall. Here is the code:
<html>
<head>
<style type="text/css">
div#outer {
margin:0 auto;
width:100%;
height:50px;
background-color:#0000FF;
border-radius:5px;
-webkit-border-radius:5px;
text-align:center;
}
#inner{
margin:0 auto;
width:95%;
height:40px;
margin-top:5px;
display:block;
background-color:#ff0000;
border-radius:5px;
-webkit-border-radius:5px;
color:#FFF;
font-size:24px;
font-family:Arial, Helvetica, sans-serif;
font-weight:bold;
line-height:40px;
text-align:center;
}
</style>
</head>
<body>
<div id="outer"><div id="inner">Centered Text goes here</div></div>
</body>
</html>
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
我给了外部 div 一个 padding-top: 5px;距离高度 -5px 希望这就是您所需要的 - http://jsfiddle.net/6Bh5x/1/< /a>
i gave the outer div a padding-top: 5px; and -5px from the height hope this is what you need - http://jsfiddle.net/6Bh5x/1/