创建带css的功能区 [英] create ribbon with css

查看:100
本文介绍了创建带css的功能区的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有侧边栏菜单终于创建。现在我需要创建功能区选择项目像显示图像(红色)(我需要真正的灰色色带)。但我不想使用图像背景和只使用CSS类。因此,我可以删除类名并添加到另一个项目。

I have sidebar menu finally created. now I need create ribbon on selected item like show image (red) (I need really gray color ribbon). But I don't want use image background and use only css class. So dynamically I can remove class name and add to another item.

我有一个 you_are_here 我想看看丝带。是否可以这样做?

I have a you_are_here class which selected item in that I want see ribbon. Is it possible to do that?

 <ul class="outer">
  <li>
    <p class="top">My Account</p>
    <ul class="inner">
      <li><a href="#">My Account Home</a></li>
    </ul>
  </li>
  <li>
    <p>Demographics</p>
    <ul class="inner">
      <li><a href="#">Addresses</a></li>
      <li class="you_are_here"><a href="#">Contact Information</a></li>
      <li><a href="#">Photo</a></li>
      <li><a href="#">Change Password</a></li>
    </ul>
  </li>

</ul>


.outer P, .inner P { padding: 0.25em 0.75em; }
.outer>LI>P { font-weight: bolder; margin: 1em 0 0 0.5em;  }
.outer>LI>P.top {
    margin: 0; background: #eee; background: linear-gradient(0deg, #DCDCDC, #F6F6F6);
    -webkit-box-shadow: 0 0 20px rgba(219,215,219,1);
    -moz-box-shadow: 0 0 20px rgba(219,215,219,1);
    -ms-box-shadow: 0 0 20px rgba(219,215,219,1);
     border-radius: 10px 10px 0px 0px;
     -moz-border-radius: 10px 10px 0px 0px;
     -webkit-border-radius: 10px 10px 0px 0px;
     border: 1px solid #bbbbbb;
     font-size: 150%;
    background-repeat:no-repeat;
    -webkit-background-size:120%;
}

.outer {
    border: 1px solid #bbb;   
    -webkit-box-shadow: 0 0 20px rgba(219,215,219,1);   
    -moz-box-shadow: 0 0 20px rgba(219,215,219,1);
    -ms-box-shadow: 0 0 20px rgba(219,215,219,1);
    box-shadow: 0 0 20px #dbd7db;
    box-shadow: 0 0 20px rgba(219,215,219,1);
    -ms-border-radius: 10px 10px 10px 10px;
    border-radius: 10px 10px 10px 10px;
    -moz-border-radius: 10px 10px 10px 10px;
    -webkit-border-radius: 10px 10px 10px 10px;
}

.outer { padding: 0;width: 90%;font-family: "Open Sans", "HelveticaNeue", "Helvetica Neue", Helvetica, Arial, sans-serif; }
UL.outer, UL.inner { list-style: none; padding: 0 }
.outer LI { padding: 0; border: none; }
.inner LI { padding: 0.25em 1.75em; border: 1px solid white;font-family: "Open Sans", "HelveticaNeue", "Helvetica Neue", Helvetica, Arial, sans-serif; }
.inner LI:hover { border: 1px solid #ddd; background: #eee; }
LI.you_are_here { background: #ddd; border: 1px solid #bbb; }
LI.you_are_here A { color: black; text-decoration: none; font-weight: bolder; }



JSfiddle



这样的东西

JSfiddle

something like this

推荐答案

这将必须适应您的需要,但使用伪元素的东西将使这成为可能:

this will have to be adapted to your needs, but something using pseudo elements would make this possible:

.box{
  height:300px;
  width:300px;
  box-shadow:inset 0 0 15px #222;
  position:relative;
  margin:0 auto;
  background:gray;
  }

.active{
  position:absolute;
  top:30px;
  left:-5%;
  height:30px;
  width:105%;
  background:tomato;
  border-radius: 5px 0 0 0;
  }
.active:before{
  content:"";
  position:absolute;
  height:16px;
  top:5px;
  left:0;
  width:100%;
  border-top:2px dashed red;
  border-bottom:2px dashed red;
  }
.active:after{
  content:"";
  position:absolute;
  right:-10px;
  height:20px;
  width:20px;
  top:5px;
  background:tomato;
  border-radius: 0 5px 0 0;
  transform:rotate(45deg);  
  }
.active a{
  position:absolute;
  top:0;
  left:0;
  height:100%;
  width:100%;
  text-align:center;
  display:inline-block;
  text-decoration:none;
  line-height:30px;
  }
.active a:after{
  content:"";
  position:absolute;
  bottom:-15px;
  left:6px;
  height:30px;
  width:30px;
  background:darkred;;
  transform:rotate(45deg);  
  z-index:-2;
  }

<div class="box">

<div class="active">
  <a href="#">some text</a>
  </div>
</div>

注意

transform属性也需要前缀。

the transform property will require prefixes as well.

这篇关于创建带css的功能区的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆