English 中文(简体)
CSS 丝带,右侧有箭内箭头
原标题:CSS ribbon with inside arrow on the right

I want to create a ribbon effect like on this image (the red part of image): ribbon example

当我试图在边界上产生箭形效果时 物体的形状会被完全摧毁

HTML 代码 :

<a href="#" class="mali_oglas_kategorija">Kategorija</a>

CSS 代码( 未尝试创建箭头) :

.mali_oglas_kategorija {        
        position: relative;
        display: inline-block; 
    font-weight: bold;
        width: 100px;        
    padding: 6px 20px 6px 40px;
    margin: 10px 10px 10px -18px;
        color: #e5e5e5 !important;
    background-color: #760000;  
    -webkit-box-shadow: 0px 2px 4px rgba(0,0,0,.5);
    -moz-box-shadow: 0px 2px 4px rgba(0,0,0,.5);
    box-shadow: 0px 2px 4px rgba(0,0,0,.5);}    
.mali_oglas_kategorija:after{
        content:    ;
    position: absolute;
    width: 0;
    height: 0;
    left: 0px;
    top: 100%;
    border-width: 5px 10px;
    border-style: solid;
    border-color: #470000 #470000 transparent transparent;
}

知道我怎么创造这个吗?

问题回答

< a href=" "http://jsfiddle. net/6uyfq/" rel="nofollow" > 这里的小提琴。 没有 b 标签无法解答它。 我使用 b 因为它太小了 。

HTML HTML

<a href="#" class="mali_oglas_kategorija">Kategorija<b></b></a>

CSS 安保部

.mali_oglas_kategorija {        
    position: relative;
    display: inline-block;
    font-weight: bold;
    width: 100px;        
    padding: 6px 20px 6px 40px;
    margin: 10px 10px 10px -18px;
    color: #e5e5e5 !important;
    background-color: #760000;  
    -webkit-box-shadow: 3px 2px 4px rgba(0,0,0,.5);
    -moz-box-shadow: 3px 2px 4px rgba(0,0,0,.5);
    box-shadow: 3px 2px 4px rgba(0,0,0,.5);}    
.mali_oglas_kategorija:before{
    content:    ;
    position: absolute;
    width: 0;
    height: 0;
    left: 0px;
    top: 100%;
    border-width: 5px 10px;
    border-style: solid;
    border-color: #470000 #470000 transparent transparent;
}

.mali_oglas_kategorija:after{
    content:    ;
    position: absolute;
    width: 0;
    height: 0;
    right: -10px;
    top: 0;
    border-width: 10px 5px;
    border-style: solid;
    border-color: #760000 transparent transparent #760000  ;
}
.mali_oglas_kategorija b {
    position: absolute;
    width: 0;
    height: 0;
    right: -10px;
    bottom: 0;
    border-width: 10px 5px;
    border-style: solid;
    border-color:  transparent transparent #760000 #760000 ;
}


body { padding: 50px;}

您也可以使用偏斜元素,如果命中测试也需要偏斜元素。

类似 :

.rib {
  margin-left: 20px;
  height: 40px;
  width: 200px;
  position: relative;
  background: gray;
  color: white;
  line-height: 40px;
  text-align: center;
}
.rib:before,
.rib:after {
  content: "";
  position: absolute;
  right: -10px;
  top: 0;
  height: 50%;
  width: 40px;
  background: inherit;
}
.rib:before {
  transform: skewX(-45deg);
}
.rib:after {
  transform: skewX(45deg);
  top: 50%;
}
.shad {
  position: absolute;
  height: 40px;
  width: 20px;
  top: 0%;
  left: 0;
  background: dimgray;
  transform-origin: top left;
  transform: skewY(45deg);
  z-index: -1;
  box-shadow:inset 0 0 10px black;
}
<div class="rib">123
  <div class="shad">
  </div>
</div>




相关问题
CSS working only in Firefox

I am trying to create a search text-field like on the Apple website. The HTML looks like this: <div class="frm-search"> <div> <input class="btn" type="image" src="http://www....

image changed but appears the same in browser

I m writing a php script to crop an image. The script overwrites the old image with the new one, but when I reload the page (which is supposed to pickup the new image) I still see the old one. ...

Firefox background image horizontal centering oddity

I am building some basic HTML code for a CMS. One of the page-related options in the CMS is "background image" and "stretch page width / height to background image width / height." so that with large ...

Separator line in ASP.NET

I d like to add a simple separator line in an aspx web form. Does anyone know how? It sounds easy enough, but still I can t manage to find how to do it.. 10x!

热门标签