使用文本框将图像放置在div后面

时间:2018-09-26 09:06:25

标签: html css image

我需要在div(container_3_text)后面放置图像的帮助。图像必须覆盖文本div后面的整个div(container_3)。我尝试过相对和绝对位置,但它不起作用,或者我做错了。 我的图片来自我的Wordpress帐户,因此我没有在链接中写它。 请帮助学生:)谢谢

.fixfloat {
  clear: both;
}
.container_3 {
  margin-bottom: 63px;
}
.container_3 img {
  height: 830px;
  width: 1840px;

}
.container_3_text {
  margin-right: 63px;
  margin-top: 290px;
  margin-bottom: 60px;
  padding-top: 50px;
  padding-bottom: 60px;
  background: white;
  display: inline-block;
  max-width: 500px;
  float: right;
}
.container_3_text .padding {
  padding-left: 30px;
  padding-right: 70px;
}
.container_3_text .text {
  min-height: 130px;
}
.container_3_heading {
  margin-bottom: 46px;
}
.container_3_heading .date {
  font-size: 20px;
  font-weight: 500px;
  float: right;
}
.container_3_heading .focus {
  background: #04fbc7;
  font-size: 20px;
  font-weight: 500px;
  letter-spacing: 0.025em;
  padding-right: 6px;
  padding-left: 12px;
  color: white;
}
.container_3_title {
  font-size: 50px;
  margin-bottom: 38px;
  line-height: 1;
}
.column_text3 {
  width: 790px;
  margin: 0 auto;
}
.column_text3 span {
  font-size: 36px;
  font-weight: 500;
}
.column_text3 p {
  font-size: 20px;
  margin-top: 18px;
  color: #b2b2b2;
}
<div class="grid_big">
  <div class="container_3">
    <img src="Image from Wordpress account" />
    <div class="container_3_text">
      <div class="padding">
        <div class="container_3_heading">
          <span class="focus">In focus</span>
          <span class="date">2018 09 05</span>
        </div>
        <div class="container_3_title">
          <p>Production/p>
        </div>
        <div class="text"> jdejdiefbghewfgewf
        </div>
        <div class="readmore">
          <span class="readmore_text">gihegegkoeef</span>
          <span class="arrow bgimgsprite"></span>
        </div>
      </div>
    </div>
    <div class="fixfloat"></div>
  </div>
</div>

4 个答案:

答案 0 :(得分:1)

您可以使用:

div.background_image{
   background: url('some_ulr');
   background-position: center;
   background-size: cover;
   background-repeat: no-repeat;
}

答案 1 :(得分:1)

只需使用background-image: url();background-size: cover

.fixfloat {
  clear: both;
}
.container_3 {
  background-image: url(https://d2v9y0dukr6mq2.cloudfront.net/video/thumbnail/rOWJ-45_eiyypas7p/film-production-light-turning-on-smoke-background_ribhftic_l_thumbnail-full03.png);
  background-position: center;
  background-size:cover;
  margin-bottom: 63px;	
}
.container_3_text {
  margin-right: 63px;
  margin-top: 290px;
  margin-bottom: 60px;
  padding-top: 50px;
  padding-bottom: 60px;
  background: white;
  display: inline-block;
  max-width: 500px;
  float: right;
}
.container_3_text .padding {
  padding-left: 30px;
  padding-right: 70px;
}
.container_3_text .text {
  min-height: 130px;
}
.container_3_heading {
  margin-bottom: 46px;
}
.container_3_heading .date {
  font-size: 20px;
  font-weight: 500px;
  float: right;
}
.container_3_heading .focus {
  background: #04fbc7;
  font-size: 20px;
  font-weight: 500px;
  letter-spacing: 0.025em;
  padding-right: 6px;
  padding-left: 12px;
  color: white;
}
.container_3_title {
  font-size: 50px;
  margin-bottom: 38px;
  line-height: 1;
}
.column_text3 {
  width: 790px;
  margin: 0 auto;
}
.column_text3 span {
  font-size: 36px;
  font-weight: 500;
}
.column_text3 p {
  font-size: 20px;
  margin-top: 18px;
  color: #b2b2b2;
}
<div class="grid_big">
  <div class="container_3">
    <div class="container_3_text">
      <div class="padding">
        <div class="container_3_heading">
          <span class="focus">In focus</span>
          <span class="date">2018 09 05</span>
        </div>
        <div class="container_3_title">
          <p>Production/p>
        </div>
        <div class="text"> jdejdiefbghewfgewf
        </div>
        <div class="readmore">
          <span class="readmore_text">gihegegkoeef</span>
          <span class="arrow bgimgsprite"></span>
        </div>
      </div>
    </div>
    <div class="fixfloat"></div>
  </div>
</div>

答案 2 :(得分:1)

尝试

.container_3_text{
background: url('some_ulr');
background-position: center;
background-size: cover;
background-repeat: no-repeat;
}

答案 3 :(得分:1)

根据您的html将.container_3_text设为绝对。

.fixfloat {
  clear: both;
}

.container_3 {
  margin-bottom: 63px;
}

.container_3 img {
  height: 830px;
  width: 1840px;
}

.container_3_text {
  right: 63px;
  top: 290px;
  margin-bottom: 60px;
  padding-top: 50px;
  padding-bottom: 60px;
  background: white;
  display: block;
  max-width: 500px;
  position: absolute;
}

.container_3_text .padding {
  padding-left: 30px;
  padding-right: 70px;
}

.container_3_text .text {
  min-height: 130px;
}

.container_3_heading {
  margin-bottom: 46px;
}

.container_3_heading .date {
  font-size: 20px;
  font-weight: 500px;
  float: right;
}

.container_3_heading .focus {
  background: #04fbc7;
  font-size: 20px;
  font-weight: 500px;
  letter-spacing: 0.025em;
  padding-right: 6px;
  padding-left: 12px;
  color: white;
}

.container_3_title {
  font-size: 50px;
  margin-bottom: 38px;
  line-height: 1;
}

.column_text3 {
  width: 790px;
  margin: 0 auto;
}

.column_text3 span {
  font-size: 36px;
  font-weight: 500;
}

.column_text3 p {
  font-size: 20px;
  margin-top: 18px;
  color: #b2b2b2;
}
<div class="grid_big">
  <div class="container_3">

    <img src="https://via.placeholder.com/830x1840" />

    <div class="container_3_text">
      <div class="padding">

        <div class="container_3_heading">
          <span class="focus">In focus</span> <span class="date">2018 09 05</span>
        </div>

        <div class="container_3_title">
          <p>Production/p>
        </div>

        <div class="text"> jdejdiefbghewfgewf
        </div>
        <div class="readmore">
          <span class="readmore_text">gihegegkoeef</span> <span class="arrow bgimgsprite"></span>
        </div>

      </div>
    </div>

    <div class="fixfloat"></div>
  </div>
</div>