Sideway旋转文本与背景

时间:2017-05-24 03:09:13

标签: css css3 css-transforms

您好我试图用css Image Link制作类似的东西。 我已尝试transform: skew(0deg, -35deg);transform: rotate(-45deg);,但背景颜色不是图像。

3 个答案:

答案 0 :(得分:0)

你可以试试这个



if ("DENY" == trim($header) ) { //remove extra spaces
...

.container{
  border: 1px solid black;
  margin: 40px;
  height: 400px;
  position: relative;
  overflow: hidden;
}

.rotated{
  background: maroon;
  color: white;
  transform: rotate(45deg);
  text-align: center;
  width: 100px;
  position: absolute;
  right: -25px;
  top: 15px;
}




答案 1 :(得分:0)

您可以将此css方法用于此



<div class="container">
  <div class="rotated">TEXT</div>
</div>
&#13;
        .card {
            width:300px;
            height: 300px;
            position: relative;
            background: #ddd;
            overflow: hidden;
        }
        .tag {
            position: absolute;
            top:5px;
            right:-24px;
            background: #990000;
            padding: 5px 30px;
            text-align: center;
            transform: rotate(45deg);
            -webkit-transform: rotate(45deg);
            color: #fff;
            font-size: 14px;

        }
&#13;
&#13;
&#13;

答案 2 :(得分:0)

好吧,我只用chrome测试过这个。我希望这可以作为你的起点。

https://jsfiddle.net/pablodarde/af5c9x78/

.container {
  display: flex;
  justify-content: center;
  align-items: center;
  width: 380px;
  height: 380px;
  background: linear-gradient(#D4EDFF, #fff);
}

.inner {
  width: 300px;
  height: 300px;
  background: #fff;
  box-shadow: 0 0 2px rgba(0,0,0,.1);
}

.holder-tag {
  position: relative;
  width: 0;
  height: 0;
  left: 300px;
}

.holder-tag .tag {
  position: absolute;
  right: -30px;
  top: 20px;
  border-bottom: 20px solid #900;
	border-left: 20px solid transparent;
	border-right: 20px solid transparent;
	height: 10px;
	width: 90px;
  transform: rotate(45deg);
}

.holder-tag span {
  position: absolute;
  right: -18px;
  top: 25px; 
  width: 110px;
  line-height: 1px;
  color: #fff;
  font: normal 14px Arial, Verdana;
  text-align: center;
  padding: 5px 0 0 0;
  box-sizing: border-box;
  transform: rotate(45deg);
}

.content {
  width: 80%;
  padding: 10px;
}
<div class="container">
  <div class="inner">
    <div class="holder-tag">
      <div class="tag"></div>
      <span>new</span>
    </div>
    <div class="content">
      <p>
      You can write text here without worrying about space.
    </p>    
    </div>
  </div>
</div>