我在超大tron的角落上有一个CSS色带。色带坐在超大tron上,但我想向上移动色带,但仍要安装在右角上。我摆弄了css类,但不确定到底要更改什么才能达到所需的最终结果。 Jumbotron是bootstrap 3-请注意。



 .ribbon-wrapper-green {
width: 180px;
height: 172px;
overflow: hidden;
position: absolute;
top: -4px;
right: -4px;
}

.ribbon-green {
  font: bold 12px Sans-Serif;
  color: #333;
  text-align: center;
  text-shadow: rgba(255,255,255,0.5) 0px 1px 0px;
  -webkit-transform: rotate(45deg);
  -moz-transform:    rotate(45deg);
  -ms-transform:     rotate(45deg);
  -o-transform:      rotate(45deg);
  position: relative;
  padding: 7px 0;
  left: -5px;
  top: 45px;
  width: 235px;
  background-color: #BFDC7A;
  background-image: -webkit-gradient(linear, left top, left bottom, from(#BFDC7A), to(#8EBF45));
  background-image: -webkit-linear-gradient(top, #BFDC7A, #8EBF45);
  background-image:    -moz-linear-gradient(top, #BFDC7A, #8EBF45);
  background-image:     -ms-linear-gradient(top, #BFDC7A, #8EBF45);
  background-image:      -o-linear-gradient(top, #BFDC7A, #8EBF45);
  color: #6a6340;
  -webkit-box-shadow: 0px 0px 3px rgba(0,0,0,0.3);
  -moz-box-shadow:    0px 0px 3px rgba(0,0,0,0.3);
  box-shadow:         0px 0px 3px rgba(0,0,0,0.3);
    white-space: nowrap;
}

.ribbon-green:before, .ribbon-green:after {
  content: "";
  border-top:   3px solid #6e8900;
  border-left:  3px solid transparent;
  border-right: 3px solid transparent;
  position:absolute;
  bottom: -3px;
}
.jumbotron {
  position: relative;
}

.ribbon-green:before {
  left: 0;
}
.ribbon-green:after {
  right: 0;
}

<html lang="en">
<head>
  <title>Bootstrap Example</title>
  <meta charset="utf-8">
  <meta name="viewport" content="width=device-width, initial-scale=1">
  <link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.4.0/css/bootstrap.min.css">
  <script src="https://ajax.googleapis.com/ajax/libs/jquery/3.4.1/jquery.min.js"></script>
  <script src="https://maxcdn.bootstrapcdn.com/bootstrap/3.4.0/js/bootstrap.min.js"></script>
</head>
<body>

<div class="container" style="margin-top:20px;">

  <div class="jumbotron" class="relative">
    <div class="ribbon-wrapper-green"><div class="ribbon-green">The Flagship Programme of<br />Aaaaa Aaaaaa Aaaaaaaaa</div></div>
    <h1>Bootstrap Tutorial</h1>
    <p>Bootstrap is the most popular HTML, CSS, and JS framework for developing responsive, mobile-first projects on the web.</p>
  </div>
  <p>This is some text.</p>
  <p>This is another text.</p>
</div>

</body>
</html>

最佳答案

我不太确定你的意思。

您是否要使色带轻轻触摸超长波管?

然后,您必须使用.ribbon-wrapper-green类的top和right属性。

像这样的东西?

.ribbon-wrapper-green {
  width: 180px;
  height: 172px;
  overflow: hidden;
  position: absolute;
  top: 0px;
  right: -3px;
}

关于css - 如何在不破坏设计的情况下向上移动色带,我们在Stack Overflow上找到一个类似的问题:https://stackoverflow.com/questions/58201853/

10-09 04:19