如何将文本放在对角线上?

How to place text on a diagonal line?

嘿 guyz,我猜你看到上面的图片就明白我的意思了。我无法将对角线放在文本后面,它应该被放置在上面的内容掩盖。我想要纯粹的 css。背景应该透过文字可见。

我想你正在找这个-

body{background: url('http://i.imgur.com/Kv22GCi.png');}
div {
  position: relative;
  width: 120px;
  margin: 100px auto;
  padding: 5px 0;
}
div:before {
  content: '';
  position: absolute;
  top: -100px; left: 45%;
  width: 1px; height: 100%;
  border-top: 120px solid #000;
  border-bottom: 120px solid #000;
  -webkit-transform: rotate(8deg);
  -ms-transform: rotate(8deg);
  transform: rotate(8deg);
}
<div>
   <h2>dsfsd jf fkljdsfjdsj</h2>
   <p>Loream ipsum dolor shit amet</p>
  </div>

希望对您有所帮助。

您可以使用伪选择器 :after:before

下载这个 image for background http://i.imgur.com/Kv22GCi.png

.container {
  position: relative;
  width: 300px;
  height: 548px;
  border: 1px solid #ccc;
  background-image: url(http://i.imgur.com/Kv22GCi.png);
  padding: 50px;
  -moz-box-sizing: border-box;
  box-sizing: border-box;
  font-family: sans-serif
}
/*For the diagonal line*/

.container:after {
  content: "";
  position: absolute;
  height: 100%;
  border: 1px solid #000;
  top: 0;
  left: 70px;
  z-index: -1;
  -moz-transform: rotate(10deg);
  -ms-transform: rotate(10deg);
  -o-transform: rotate(10deg);
  -webkit-transform: rotate(10deg);
  transform: rotate(10deg)
}
h1 {
  font-size: 50px
}
p {
  font-size: 22px
}
<div class="container">
  <h1>About Us.</h1>

  <p>"Lorem ipsum sit amet.Lorem ipsum sit amet.Lorem ipsum sit amet.Lorem ipsum sit amet.Lorem ipsum sit amet.Lorem ipsum sit amet.Lorem ipsum sit amet."
    <p/>
</div>

您可以使用旋转的伪元素。将它设为 1px 宽,并用 top/bottom 边框制作线条:

body {
  padding: 0;
  margin: 0;
  background-image: url('https://farm7.staticflickr.com/6083/6055581292_d94c2d90e3.jpg');
  background-size: cover;
}

div {
  position: relative;
  width: 150px;
  margin: 130px auto;
  padding: 10px 0;
}

div:before {
  content: '';
  position: absolute;
  top: -120px;
  left: 50%;
  width: 1px;
  height: 100%;
  border-top: 120px solid #000;
  border-bottom: 120px solid #000;
  -webkit-transform: rotate(8deg);
  -ms-transform: rotate(8deg);
  transform: rotate(8deg);
}
<div>
  <h1>Title</h1>
  <p>Lorem ipsum dolor sit amet, consectetur adipiscing elit. Donec luctus condimentum mi sit amet iaculis. Aliquam erat volutpat. Maecenas eleifend commodo rutrum.</p>
</div>