菜单的ul li css问题

时间:2018-11-13 06:19:19

标签: css css3

我正在尝试从锚标签更改为ul li,但似乎不起作用。

您能找到我需要更改代码CSS的地方吗?

原始链接:https://codepen.io/arkev/pen/DzCKF

我的代码:https://codepen.io/SankS/pen/YRNzGK

<ul>
    <li><a href="#" class="active">Browse</a></li>
    <li><a href="#">Compare</a></li>
    <li><a href="#">Order Confirmation</a></li>
    <li><a href="#">Checkout</a></li>
</ul>

3 个答案:

答案 0 :(得分:0)

尝试左移li标签以获得水平外观:

.breadcrumb li {
  float: left;
}

答案 1 :(得分:0)

尝试一下,我认为这会对您有所帮助

.flat ul li{
  float:left;
}

答案 2 :(得分:0)

css中的较小更改,并将“活动”类更改为li元素

/*custom font*/

@import url(https://fonts.googleapis.com/css?family=Merriweather+Sans);
* {
  margin: 0;
  padding: 0;
}

html,
body {
  min-height: 100%;
}
a{text-decoration:none;}
body {
  text-align: center;
  padding-top: 100px;
  background: #689976;
  background: linear-gradient(#689976, #ACDACC);
  font-family: 'Merriweather Sans', arial, verdana;
}

.breadcrumb {
  /*centering*/
  display: inline-block;
  box-shadow: 0 0 15px 1px rgba(0, 0, 0, 0.35);
  overflow: hidden;
  border-radius: 5px;
  /*Lets add the numbers for each link using CSS counters. flag is the name of the counter. to be defined using counter-reset in the parent element of the links*/
  counter-reset: flag;
}
.breadcrumb li {
  text-decoration: none;
  outline: none;
  display: block;
  float: left;
  font-size: 12px;
  line-height: 36px;
  color: white;
  /*need more margin on the left of links to accomodate the numbers*/
  padding: 0 10px 0 60px;
  background: #666;
  background: linear-gradient(#666, #333);
  position: relative;
}

/*since the first link does not have a triangle before it we can reduce the left padding to make it look consistent with other links*/

.breadcrumb li:first-child {
  padding-left: 46px;
  border-radius: 5px 0 0 5px;
  /*to match with the parent's radius*/
}

.breadcrumb li:first-child:before {
  left: 14px;
}

.breadcrumb li:last-child {
  border-radius: 0 5px 5px 0;
  /*this was to prevent glitches on hover*/
  padding-right: 20px;
}


/*hover/active styles*/

.breadcrumb li.active,
.breadcrumb a:hover {
  background: #333;
  background: linear-gradient(#333, #000);
}

.breadcrumb li.active:after,
.breadcrumb li:hover:after {
  background: #333;
  background: linear-gradient(135deg, #333, #000);
}


/*adding the arrows for the breadcrumbs using rotated pseudo elements*/

.breadcrumb li:after {
  content: '';
  position: absolute;
  top: 0;
  right: -18px;
  /*half of square's length*/
  /*same dimension as the line-height of .breadcrumb a */
  width: 36px;
  height: 36px;
  /*as you see the rotated square takes a larger height. which makes it tough to position it properly. So we are going to scale it down so that the diagonals become equal to the line-height of the link. We scale it to 70.7% because if square's: 
	length = 1; diagonal = (1^2 + 1^2)^0.5 = 1.414 (pythagoras theorem)
	if diagonal required = 1; length = 1/1.414 = 0.707*/
  transform: scale(0.707) rotate(45deg);
  /*we need to prevent the arrows from getting buried under the next link*/
  z-index: 1;
  /*background same as links but the gradient will be rotated to compensate with the transform applied*/
  background: #666;
  background: linear-gradient(135deg, #666, #333);
  /*stylish arrow design using box shadow*/
  box-shadow: 2px -2px 0 2px rgba(0, 0, 0, 0.4), 3px -3px 0 2px rgba(255, 255, 255, 0.1);
  /*
		5px - for rounded arrows and 
		50px - to prevent hover glitches on the border created using shadows*/
  border-radius: 0 5px 0 50px;
}


/*we dont need an arrow after the last link*/

.breadcrumb li:last-child:after {
  content: none;
}


/*we will use the :before element to show numbers*/

.breadcrumb li:before {
  content: counter(flag);
  counter-increment: flag;
  /*some styles now*/
  border-radius: 100%;
  width: 20px;
  height: 20px;
  line-height: 20px;
  margin: 8px 0;
  position: absolute;
  top: 0;
  left: 30px;
  background: #444;
  background: linear-gradient(#444, #222);
  font-weight: bold;
}

.flat li,
.flat li:after {
  background: white;
  color: black;
  transition: all 0.5s;
}
.flat li a {color:black;}
.flat li a:hover{background:none;}
.flat li:before {
  background: white;
  box-shadow: 0 0 0 1px #ccc;
}

.flat li:hover,
.flat li.active,
.flat li:hover:after,
.flat li.active:after {
  background: #9EEB62;
}
<!-- a simple div with some links -->

<!-- another version - flat style with animated hover effect -->
<div class="breadcrumb flat">
  <ul>
    <li class="active">
      <a href="#">Browse</a>
    </li>
    <li><a href="#">Compare</a></li>
    <li><a href="#">Order Confirmation</a></li>
    <li><a href="#">Checkout</a></li>
  </ul>
</div>

<!-- Prefixfree -->
<script src="http://thecodeplayer.com/uploads/js/prefixfree-1.0.7.js" type="text/javascript" type="text/javascript"></script>