这是一个例子。 http://jsfiddle.net/52c7t/
简单地说:我正试图让右边的div,左边有一个像div这样的边框。 (我希望边框位于右边div的左侧)
我尝试了一百万种不同的组合,但却无法做到。我试图避免制作图像并使用CSS执行此操作。
感谢您的帮助!
更新:
我的意思的形象。抱歉,我的平面设计技巧:P
HTML
<div id = "top_bar">
<div id="top_left_button" >border</div>
<div class = "trapezoid"> none </div>
</div>
CSS
.trapezoid{
vertical-align: middle;
position:absolute;
border-bottom: 60px solid blue;
border-left: 45px solid transparent;
border-top-left-radius:30px;
*border-top-right-radius:15px;
*border-bottom-right-radius:3px;
height: 0;
width: 50px;
display: inline-block;
right:1px;
}
#top_bar{
background-color: #000;
border-bottom: 1px solid #666;
color: #222;
position:fixed;
left:0px;
top: 0px;
width:100%;
overflow:hidden;
height: 50%;
font-weight: normal;
white-space: nowrap;
color: white;
z-index:20;
line-height: 45px;
min-width:320px;
max-width: 320px;
max-height:48px;
border-radius: 5px;
text-shadow: rgba(0,0,0,0.6) 0px -1px 0px;
}
#top_bar:after {
content: '';
width: 10%;
display: inline-block;
font-size: 0;
line-height: 0
}
#top_title, #top_left_button, #notifications, #top_right_button {
color: white;
height: 100%;
overflow:hidden;
display: inline-block;
text-align: center;
vertical-align: middle;
}
#top_left_button,#top_right_button{
width: 20%;
background: rgba( 100, 255, 255, .1 );
}
#top_left_button{
border-right: 2px solid #666;
}
编辑:更新链接
答案 0 :(得分:3)
简单的解决方案是创建另一个div,因为你的蓝色div已经使用border属性组成了。
新的div实际上是蓝色div的克隆,但是将使用CSS width属性将其着色为红色并稍大一些。这成为蓝色div的伪边框。
新div的例子:
.trapezoid-border{
vertical-align: middle;
position:absolute;
border-bottom: 60px solid red; /* Color Changed will be pseudo-border color */
border-left: 45px solid transparent;
border-top-left-radius:30px;
*border-top-right-radius:15px;
*border-bottom-right-radius:3px;
height: 0;
width: 53px; /* Extra 3 pix when compared to .trapezoid class width */
display: inline-block;
right:1px;
}
答案 1 :(得分:1)
坦率地说,我认为你应该使用一个图像,但是如果你真的想要或必须避免这种情况,那么有点肮脏(虽然我认为非常令人信服的)修复将是创建一个固定大小的红色{{1你定位和旋转(使用<div>
属性)恰到好处地达到了适当的效果。
transform
关于jsfiddle:http://jsfiddle.net/QBTpV/18/
(在Chrome和IE中测试)