如何制作响应式条带

时间:2016-08-18 16:44:09

标签: html css twitter-bootstrap rotation translate

我用css在我的网站上建立一个斜条纹。问题是我把它放在我的屏幕右侧,所以乐队的宽度使我的网站没有响应(总宽度超过100%)。我使用bootstrap作为框架,为了创建条带,我在其上添加了一个旋转和翻译值。有没有办法减少剩余的?这是我的代码:



.contact-triangle {
  z-index: -1;
  width: 23%;
  position: relative;
  left: 90%;
  top: -6%;
  width: 263px;
  -webkit-transform-origin: 0 0;
  -moz-transform-origin: 0 0;
  -ms-transform-origin: 0 0;
  -o-transform-origin: 0 0;
  transform-origin: 0 0;
  -webkit-transform: rotate(-37deg) translate(-92px, 22px);
  -moz-transform: rotate(-37deg) translate(-92px, 22px);
  -ms-transform: rotate(-37deg) translate(-92px, 22px);
  -o-transform: rotate(-37deg) translate(-92px, 22px);
  transform: rotate(-37deg) translate(-92px, 22px);
  background-color: white;
  text-align: center;
  line-height: 1.5em;
  background-color: #353538;
}
.contact-triangle a {
  margin-right: 33px;
  display: block;
  color: white;
  padding: .5em 1em;
  text-decoration: none;
}
.container-fluid.triangle {
  max-width: 100%;
}

<!DOCTYPE html>
<html lang="en">

<head>
  <meta charset="UTF-8">
  <title>Document</title>
  <link rel='stylesheet' id='bootstrap-css' href='https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap.min.css' type='text/css' media='all' />

</head>

<body>
  <div class="container-fluid triangle">
    <div class="contact-triangle">
      <a href="#">Do you want to join us?</a>
    </div>
  </div>
</body>

</html>
&#13;
&#13;
&#13;

1 个答案:

答案 0 :(得分:1)

基本上使用了容器的fixed位置并删除了contact-triangle的位置,然后你就去了!

请检查一下,如果您正在寻找,请告诉我。谢谢!

&#13;
&#13;
.contact-triangle {
  width: 263px;
  -webkit-transform-origin: 0 0;
  -moz-transform-origin: 0 0;
  -ms-transform-origin: 0 0;
  -o-transform-origin: 0 0;
  transform-origin: 0 0;
  -webkit-transform: rotate(-37deg) translate(-92px, 22px);
  -moz-transform: rotate(-37deg) translate(-92px, 22px);
  -ms-transform: rotate(-37deg) translate(-92px, 22px);
  -o-transform: rotate(-37deg) translate(-92px, 22px);
  transform: rotate(-37deg) translate(-92px, 22px);
  background-color: white;
  text-align: center;
  line-height: 1.5em;
  background-color: #353538;
}
.contact-triangle a {
  text-align: left;
  display: block;
  color: white;
  padding: .5em 1em;
  text-decoration: none;
}
.container-fluid.triangle {
  max-width: 100%;
  position: fixed;
  right: -190px;
  top: 20px;
}
&#13;
<!DOCTYPE html>
<html lang="en">

<head>
  <meta charset="UTF-8">
  <title>Document</title>
  <link rel='stylesheet' id='bootstrap-css' href='https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap.min.css' type='text/css' media='all' />

</head>

<body>
  <div class="container-fluid triangle">
    <div class="contact-triangle">
      <a href="#">Do you want to join us?</a>
    </div>
  </div>
</body>

</html>
&#13;
&#13;
&#13;