DEV Community

Ruxin Qu
Ruxin Qu

Posted on

CSS: Create a breadcrumb

Breadcrumb example 1

Breadcrumb example 1

<!DOCTYPE html>
<html>
<head>
<meta name="viewport" content="width=device-width, initial-scale=1">
<style>
ul.breadcrumb{
    list-style: none;
    padding: 15px;
    background-color: lightgray;

}

ul.breadcrumb li{
    display: inline-block;
    font-size: 20px;
    font-family: sans-serif;
}

ul.breadcrumb a{
    text-decoration: none;
}

ul.breadcrumb li+li::before{
    content: '/\00a0';
    padding: 8px;
}

ul.breadcrumb a:hover{
    text-decoration: underline;
    cursor: pointer;
}
</style>
</head>
<body>

<h2>Breadcrumb Pagination</h2>
<ul class="breadcrumb">
  <li><a href="#">Home</a></li>
  <li><a href="#">Pictures</a></li>
  <li><a href="#">Dahuang</a></li>
  <li>Beach</li>
</ul>

</body>
</html>
Enter fullscreen mode Exit fullscreen mode

Breadcrumb example 2

Image description

.breadcrumb {
    text-align: left;

  }
  .breadcrumb li{
    list-style: none;
    float: left;
  }
  .breadcrumb a {
    display: block;
    text-align: center;
    color: #fff;
    background-color: darkcyan;
    text-decoration: none;
    position: relative;
    height: 30px;
    line-height: 30px;
    margin-right: 15px;
    padding: 0 5px;
  }

  .breadcrumb  a::before,
  .breadcrumb  a::after {
    content: "";
    position: absolute;
    border-color: darkcyan;
    border-style: solid;
    border-width: 15px 5px;
  }

  .breadcrumb  a::after {
    left: 100%;
    border-color: transparent;
    border-left-color: darkcyan;
  }
  .breadcrumb  a::before {
    left: -10px;
    border-left-color: transparent;
  }

  .breadcrumb  a:hover {
    background-color: blue;
  }
  .breadcrumb  a:hover::before {
    border-color: blue;
    border-left-color: transparent;
  }
  .breadcrumb  a:hover::after {
    border-left-color: blue;
  }
Enter fullscreen mode Exit fullscreen mode

Top comments (0)