在悬停UL菜单时,从左向右滑动边框

时间:2016-10-19 08:37:11

标签: html css border

我希望此边框从左向右滑动(仅限dropmenus)。但无法弄清楚

这是我到目前为止的方式,我不再有任何想法。

菜单是用ul和li-s构建的。

这可能吗?

谢谢,



.toggle,
[id^=drop] {
	display: none;
}
.toggle_menu,
[id^=drop] {
	display: none;
}
nav:after {
	content:"";
	display:table;
	clear:both;
}
nav ul {
	padding:0;
	margin:0;
	list-style: none;
	position: relative;
	}
nav ul li.active_link a{
	font-size:14px;
	text-decoration:none;
	font-family: 'Lato';
	font-weight:600;
}
nav ul li {
	margin: 0px;
	display:inline-block;
	float: left;
	background-color: white;
	}
nav a {
	display:block;
	    padding: 14px 16px;
	color:#FFF;
	font-size:14px;
	text-decoration:none;
	color:black;
	font-family: 'Lato';
	font-weight:400;
}

nav ul li ul li:hover { /*background: #000000; */}
nav a:hover { 
	/*background-color: #000000;*/ 
}
nav ul li ul{
	display: none;
	position: absolute;
	  color: #31302B;
    background: #FFF;
    cursor: pointer;
    box-shadow: inset 0 0 0 0 #b6945d;
	-webkit-transition: all ease 1s;
	-moz-transition: all ease 1s;
	transition: all ease 1s;
}
nav ul li:hover > ul{
    box-shadow: inset 900px 0px 0px #b6945d;
    color: #fff;
}
nav ul li:hover > ul {
	display:inherit;
}
nav ul ul li {
	    background-color: transparent;
    width: auto;
    float: left;
    display: list-item;
    position: relative;
}
nav ul ul ul li {
	position: relative;
	top:-60px;
	left:170px; 
}
nav ul li ul li a{
    font-style: italic;
    background-color: white;
    margin-top: 1px;
}
nav ul li ul li a:hover{
	font-style:italic;
	color:#b6945d;
}
/*li > a:after { content:  ' +'; }*/
li > a:only-child:after { content: ''; }

        <nav>
        <label for="drop" class="toggle_menu"><img src="assets/images/mobile_button.png"></label>

        <input type="checkbox" id="drop" />
            <ul class="menu">
                <li class="active_link">
					<a href="#">Avaleht</a>
				</li>
                <li>
                    <label for="drop-1" class="toggle">Kunstnik</label><a href="#">Kunstnik</a>
                    <input type="checkbox" id="drop-1"/>
                    <ul>
                        <li><a href="#">Kunstnikust</a></li>
                        <li><a href="#">Tööde arhiiv</a></li>
                    </ul> 
                </li>
                <li>
					<label for="drop-2" class="toggle">E-pood</label><a href="#">E-pood</a>
					<input type="checkbox" id="drop-2"/>
					<ul>
						<li><a href="#">Kõik tooted</a></li>
						<li><a href="#">Seeriatooted</a></li>
					</ul>
                </li>
            </ul>
        </nav>
&#13;
&#13;
&#13;

2 个答案:

答案 0 :(得分:0)

  

我在下面添加了10行css:你在找这个:

.toggle,
[id^=drop] {
	display: none;
}
.toggle_menu,
[id^=drop] {
	display: none;
}
nav:after {
	content:"";
	display:table;
	clear:both;
}
nav ul {
	padding:0;
	margin:0;
	list-style: none;
	position: relative;
	}
nav ul li.active_link a{
	font-size:14px;
	text-decoration:none;
	font-family: 'Lato';
	font-weight:600;
}
nav ul li {
	margin: 0px;
	display:inline-block;
	float: left;
	background-color: white;
	}
nav a {
	display:block;
	    padding: 14px 16px;
	color:#FFF;
	font-size:14px;
	text-decoration:none;
	color:black;
	font-family: 'Lato';
	font-weight:400;
}

nav ul li ul li:hover { /*background: #000000; */}
nav a:hover { 
	/*background-color: #000000;*/ 
}
nav ul li ul{
	display: none;
	position: absolute;
	  color: #31302B;
    background: #FFF;
    cursor: pointer;
    box-shadow: inset 0 0 0 0 #b6945d;
	-webkit-transition: all ease 1s;
	-moz-transition: all ease 1s;
	transition: all ease 1s;
}
nav ul li:hover > ul{
    box-shadow: inset 900px 0px 0px #b6945d;
    color: #fff;
}
nav ul li:hover > ul {
	display:inherit;
}
nav ul ul li {
	    background-color: transparent;
    width: auto;
    float: left;
    display: list-item;
    position: relative;
}
nav ul ul ul li {
	position: relative;
	top:-60px;
	left:170px; 
}
nav ul li ul li a{
    font-style: italic;
    background-color: white;
    margin-top: 1px;
}
nav ul li ul li a:hover{
	font-style:italic;
	color:#b6945d;
}
/*li > a:after { content:  ' +'; }*/
li > a:only-child:after { content: ''; }




/**New css for transition**/
nav ul li ul:after {
  content: '';
  display: block;
  border-bottom: 4px solid red;
  width: 0;
  position: absolute;
  left: 0;
  -webkit-transition: 1s ease;
  transition: 1s ease;
}
nav ul li ul:hover:after { 
  width: 100%; 
}
<nav>
        <label for="drop" class="toggle_menu"><img src="assets/images/mobile_button.png"></label>

        <input type="checkbox" id="drop" />
            <ul class="menu">
                <li class="active_link">
					<a href="#">Avaleht</a>
				</li>
                <li>
                    <label for="drop-1" class="toggle">Kunstnik</label><a href="#">Kunstnik</a>
                    <input type="checkbox" id="drop-1"/>
                    <ul>
                        <li><a href="#">Kunstnikust</a></li>
                        <li><a href="#">Tööde arhiiv</a></li>
                    </ul> 
                </li>
                <li>
					<label for="drop-2" class="toggle">E-pood</label><a href="#">E-pood</a>
					<input type="checkbox" id="drop-2"/>
					<ul>
						<li><a href="#">Kõik tooted</a></li>
						<li><a href="#">Seeriatooted</a></li>
					</ul>
                </li>
            </ul>
        </nav>

答案 1 :(得分:0)

现在可行。

.menu {
  width: 100%;
  height: auto;
  background: white;
  transition: all 0.3s ease;
}
.menu ul {
  padding: 0px;
  margin: 0px;
  list-style: none;
  position: relative;
  display: inline-block;
  width:100%;
}
.menu > li > ul.sub_menu {
  min-width: 10em;
  padding: 4px 0;
  background-color: #f4f4f4;
  border: 1px solid #fff;
}

.menu ul li { padding: 0px; }
.menu ul li.active a{
	font-weight:600;
}
.second_menu ul li.active a{
	font-weight:600;
}
.menu > ul > li { display: inline-block; }
.menu ul li a {
  display: block;
  text-decoration: none;
  color: black;
	font-family: 'Lato';
	font-weight:400;
	font-size:14px;
}

.menu ul li a:hover {
  color: black;
}

.menu ul li.hover > a {
  color: black;
}

.menu ul li > a { padding: 15px; }

.menu ul ul {
  visibility: hidden;
  position: absolute;
  top: 100%;
  width:auto;
  background: white;
}
.menu ul li.active_drop a{
	font-weight:600 !important;
	color:#b6945d;
}
.menu ul li ul.dropdown_nav li a{
	font-weight:400;
}
.menu ul li.active_drop a:hover{
	color:#b6945d;
}
.menu ul li:hover > ul {
    visibility: visible;
}
.menu ul ul > li { 
	position: relative; 
    display: inline;
    float: left;
    width: auto;
}
.menu ul ul > li a {
  padding: 10px 15px;
  height: auto;
  background: white;
  font-style:italic;
}

.menu ul ul > li a:hover {
  color: black;
}

.menu ul ul ul {
  position: absolute;
  left: 100%;
  top: 0;
}


/* animating the golden border */
.dropdown_nav {
    position: relative;
    overflow: hidden;
}
.dropdown_nav:before {
  position: absolute;
  display: block;
  top: 0;
  left: 0;
  width: 100%;
  height: 1px;
  content: "";
  background-color: #b6945d;
  z-index: 1;
  transition: transform .5s ease-out;
  transform: translateX(-100%);
}
.menu>ul>li:hover .dropdown_nav:before {
  transform: translateX(0);
}
<nav id="menu" class="menu">
						<ul class="dropdown">
						  <li><a href="#">leht</a></li>
						  <li class="active">
							<a href="#">leht1</a>
							<ul class="dropdown_nav">
							  <li class="dropdown_first active_drop">
                  <a href="#">leht1.1</a></li>
							  <li class="dropdown_last"><a href="#">leht1.2</a></li>
							</ul>
						  </li>
						  <li>
							<a href="#">leht2</a>
							<ul class="dropdown_nav">
							  <li class="dropdown_first"><a href="#">leht2.1</a></li>
							  <li><a href="#">leht2.2</a></li>
							</ul>
						  </li>
						  <li><a href="#">leht3</a></li>
						  <li><a href="#">leht4</a></li>
						</ul>
					  </nav>