2

我想在这个图像上创建一个丝带效果(图像的红色部分): 功能区示例

当我尝试创建带边框的箭头效果时,对象的形状被完全破坏:

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;
}

知道如何创建这个吗?

4

2 回答 2

3

在这里做了一个小提琴。虽然没有ab标签无法解决它。我用 b 因为它太小了

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;}
于 2012-05-30T11:16:59.023 回答
1

如果命中测试也需要这样做,您也可以使用倾斜元素。

就像是:

.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>

于 2015-05-06T10:43:37.050 回答