导航栏上带有三角形的不需要的边框

时间:2017-09-15 13:15:35

标签: css css3 responsive-design navbar



html, body {
  height: 100%;
  overflow: auto;
  margin: 0 auto;
  padding: 0;
  
}
body {
  font-family: 'Roboto', sans-serif;
  height:100vh;
  margin: 0 auto;
}
/* Total Container, incl. Navbar and Footer */
.bckg {
  height: 100vh;
  background-image: url('images/zzzleft.jpg'), url('images/zzzright.jpg');
  background-position: top left, top right;
  background-repeat: repeat-y;
  max-width: 2270px;
}
/* Middle Section Container */
.centerSection {
  overflow-y:scroll;
  height: 100vh;
  width: 72%;
  margin: 0 auto;
  background: white;
  border: none;
}
/* All Content Between Nav and Footer */
.row {
  padding: 10px 30px 20px 40px;
}
.navbar {
  list-style-type: none;
  margin-top: 0;
  padding-top: 0;
  padding: 0;
  height: 100px;
  display: flex;
}
.navLogo {
  margin: 0 auto;
  margin-left: 26%;
  margin-top: 0;
  margin-bottom: 7%;
}
.navTalkText {
  color: white;
  text-align: right;
  display: block;
  position: relative;
  top: 50%;
  transform: translateY(-50%);
  padding-right: 30px;
  font-size: 12px;
}
.rightsideNav {
  width: 78%;
  margin-left: auto;
  overflow: hidden;
}
.centered {
  padding-bottom: 18px;
  font-size: 13px;
  
  letter-spacing: -.5px;
}
.leftSideNav {
  width: 20%;
  
}
.red-strip {
  background: #ce3229;
  height: 37px;
  position: relative;
  border-color: white;
}
.dark-strip {
  background: #2d2d2c;
  height: 37px;
  position: relative;
  border-color: white;
}
.red-strip:before {
  content: "";
  position: absolute;
  top: 0;
  width: 0;
  height: 0;
  border-style: solid;
  border-width: 0 18px 37px 18px;
  border-color: transparent transparent #a9282b #fff;
}
.dark-strip:before {
  content: "";
  position: absolute;
  top: 0;
  width: 0;
  height: 0;
  border-style: solid;
  border-width: 37px 18px 0 18px;
  border-color: #0c0c0c transparent transparent #fff;
}
li {
    float: right;
    padding-bottom: 22px;
    display: block;
    position: relative;
    top: 50%;
    transform: translateY(-38%);
    padding-left: 0;
}
li a, .dropbtn {
    display: inline-block;
    color: white;
    text-align: center;
    padding: 14px 16px;
    text-decoration: none;
}
li a:hover, .dropdown:hover .dropbtn {
    background-color: red;
}
li.dropdown {
    display: inline-block;
}
.dropdown-content {
    display: none;
    position: absolute;
    background-color: #f9f9f9;
    min-width: 160px;
    box-shadow: 0px 8px 16px 0px rgba(0,0,0,0.2);
    z-index: 1;
}
.dropdown-content a {
    color: black;
    padding: 12px 16px;
    text-decoration: none;
    display: block;
    text-align: left;
}
.dropdown-content a:hover {background-color: #f1f1f1}
.dropdown:hover .dropdown-content {
    display: block;
}

<!DOCTYPE html>
<html>
  <head>
    <meta charset="UTF-8">
    <title>title</title>
  </head>
  <body>
    <div class="bckg">
    <div class="centerSection">
      <ul class="navbar">
  <div class="leftsideNav">
    <a href="../index.php">
      <img src="images/trans_logo.jpg" width="160" class="navLogo" alt="navbar_logo" />
    </a>
  </div>
  <div class="rightsideNav">
    <div class="red-strip">
      <p class="navTalkText">Ready to talk? 860-659-0777</p>
    </div>
    <div class="dark-strip">
      <li class="centered"><a href="contact.php">CONTACT</a></li>
      <li class="centered"><a href="resources.php">RESOURCES</a></li>
      <li class="centered"><a href="about.php">ABOUT</a></li>
      <li class="centered"><a href="industries.php">INDUSTRIES</a></li>
      <li class="centered"><a href="services.php">SERVICES</a></li>
      <li class="centered"><a href="solutions.php">SOLUTIONS</a></li>
      <li class="centered"><a href="work.php">WORK</a></li>
    </div>
  </div>
</ul>
      <div class="content">
        <div class="row">
        <div class="col-6">
          <h1>What is Lorem Ipsum?</h1>
          <p>Lorem Ipsum is simply dummy text of the printing and typesetting industry. Lorem Ipsum has been the industry's standard dummy text ever since the 1500s, when an unknown printer took a galley of type and scrambled it to make a type specimen book. It has survived not only five centuries, but also the leap into electronic typesetting, remaining essentially unchanged. It was popularised in the 1960s with the release of Letraset sheets containing Lorem Ipsum passages, and more recently with desktop publishing software like Aldus PageMaker including versions of Lorem Ipsum.</p>
        </div>
        <div class="col-6">
          <h1>Why do we use it?</h1>
          <p>It is a long established fact that a reader will be distracted by the readable content of a page when looking at its layout. The point of using Lorem Ipsum is that it has a more-or-less normal distribution of letters, as opposed to using 'Content here, content here', making it look like readable English. Many desktop publishing packages and web page editors now use Lorem Ipsum as their default model text, and a search for 'lorem ipsum' will uncover many web sites still in their infancy. Various versions have evolved over the years, sometimes by accident, sometimes on purpose (injected humour and the like).</p>
        </div>
      </div>
      <div class="row">
        <div class="col">
          <h1>1 of 3</h1>
          <p>Lorem Ipsum is simply dummy text of the printing and typesetting industry. Lorem Ipsum has been the industry's standard dummy text ever since the 1500s, when an unknown printer took a galley of type and scrambled it to make a type specimen book. It has survived not only five centuries, but also the leap into electronic typesetting, remaining essentially unchanged. It was popularised in the 1960s with the release of Letraset sheets containing Lorem Ipsum passages, and more recently with desktop publishing software like Aldus PageMaker including versions of Lorem Ipsum.</p>
        </div>
        <div class="col">
          <h1>2 of 3</h1>
          <p>It is a long established fact that a reader will be distracted by the readable content of a page when looking at its layout. The point of using Lorem Ipsum is that it has a more-or-less normal distribution of letters, as opposed to using 'Content here, content here', making it look like readable English. Many desktop publishing packages and web page editors now use Lorem Ipsum as their default model text, and a search for 'lorem ipsum' will uncover many web sites still in their infancy. Various versions have evolved over the years, sometimes by accident, sometimes on purpose (injected humour and the like).</p>
        </div>
        <div class="col-5">
          <h1>3 of 3 (wider)</h1>
          <p>Contrary to popular belief, Lorem Ipsum is not simply random text. It has roots in a piece of classical Latin literature from 45 BC, making it over 2000 years old. Richard McClintock, a Latin professor at Hampden-Sydney College in Virginia, looked up one of the more obscure Latin words, consectetur, from a Lorem Ipsum passage, and going through the cites of the word in classical literature, discovered the undoubtable source. Lorem Ipsum comes from sections 1.10.32 and 1.10.33 of "de Finibus Bonorum et Malorum" (The Extremes of Good and Evil) by Cicero, written in 45 BC. This book is a treatise on the theory of ethics, very popular during the Renaissance. The first line of Lorem Ipsum, "Lorem ipsum dolor sit amet..", comes from a line in section 1.10.32.</p>
          <p>The standard chunk of Lorem Ipsum used since the 1500s is reproduced below for those interested. Sections 1.10.32 and 1.10.33 from "de Finibus Bonorum et Malorum" by Cicero are also reproduced in their exact original form, accompanied by English versions from the 1914 translation by H. Rackham.</p>
        </div>
      </div>
      
    </div>
  </body>
</html>
&#13;
&#13;
&#13;

小CSS问题我很难自己解决...

Navbar由两个div(红色和灰色条)组成,使用:在psuedo类之前向左侧创建三角形,如图所示。在某些决议中,出现了这些奇怪的轮廓。我怎么摆脱他们? 以下是该问题的图片:

Unwanted Lines Around Nav

.red-strip {
  background: #ce3229;
  height: 37px;
  position: relative;
  border: none;
  border-color: white;
  padding-right: 16px;
}
.dark-strip {
  background: #2d2d2c;
  height: 37px;
  position: relative;
  border: none;
  border-color: white;
  padding-right: 16px;
}
.red-strip:before {
  content: "";
  position: absolute;
  display: inline;
  top: 0;
  width: 0;
  height: 0;
  border-style: solid;
  border-width: 0 18.5px 37px 18.5px;
  border-color: transparent transparent #a9282b #fff;
}
.dark-strip:before {
  content: "";
  position: absolute;
  display: inline;
  top: 0;
  width: 0;
  height: 0;
  border-style: solid;
  border-width: 37px 18.5px 0 18.5px;
  border-color: #0c0c0c transparent transparent #fff;
}

其他可能相关的CSS:

.rightsideNav {
  width: 78%;
  margin-left: auto;
  overflow: hidden;
}
.navbar {
  list-style-type: none;
  margin: 0;
  padding: 0;
  background-color: white;
  height: 74px;
  display: flex;
}
/* Total Container, incl. Navbar and Footer */
.bckg {
  height: 100vh;
  background-image: url('images/zzzleft.jpg'), url('images/zzzright.jpg');
  background-position: top left, top right;
  background-repeat: repeat-y;
  max-width: 2270px;
}

Navbar也在此范围内:

/* Middle Section Container */
.centerSection {
  overflow-y:scroll;
  height: 100vh;
  width: 72%;
  margin: 0 auto;
  background: white;
  border: none;
}

1 个答案:

答案 0 :(得分:0)

实际上颜色不同就是创建边框的原因。 请使用style.css中的代码,或者您可以编辑您的代码并使用以下边框颜色的exing css文件

.red-strip:在{

之前
    border-color: transparent transparent #ce3229 #fff !important;
}
.dark-strip:before {

    border-color: #2d2d2c transparent transparent #fff !important;
}