Can I create border-bottom without diagonal corner? [duplicate]

笑着哭i 提交于 2019-11-29 19:22:33

问题


This question already has an answer here:

  • Removing the Bevel Effect on the Corner of Borders 2 answers

I want to create a box with different color, left,right and top color red and bottom color is grey but I want flat bottom-border of box

HTML

<div class="ts"></div>

CSS

.ts {    
    height:100px;
    width:100px;
    border-width:10px 10px 20px 10px;
    border-style:solid;
    border-color:#f00 #f00 #ddd #f00;
}

When I create it with above code, It seems like this

But I don't want bottom-border as diagonal corner, I want it as;

http://jsfiddle.net/3jHG8/

Is there an easy way to do it as crossbrowser?


回答1:


Just use css box-shadow as follow:

JSFIDDLE DEMO 1

HTML

<div class="ts"></div>

CSS

.ts {    
    height:100px;
    width:100px;
    border-width:10px 10px 0px 10px;
    border-style:solid;
    border-color:#f00 #f00 transparent #f00;
    box-shadow: 0 20px 0 #ddd;
}

or box-shadow only:

.ts {
height: 100px;
width: 100px;
box-shadow: inset 0 10px 0 0 #f00,inset 10px 0 0 0 #f00,inset -10px 0 0 0 #f00, 0 20px 0 #ddd;
}

JSFIDDLE DEMO 2

Use CSS3 PIE, to emulates some text-shadow in older versions of in IE7 and IE8.




回答2:


What you are asking is not possible. Instead you can use something like this:

<div class="ts">sample text sample text sample text sample text sample text</div>

.ts {    
 height:100px;
 width:100px;
 padding:10px;
 border-bottom:10px solid #dfd;
 background-color:#f00;
}

Hope this helps.



来源:https://stackoverflow.com/questions/22534084/can-i-create-border-bottom-without-diagonal-corner

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!