user9924086
user9924086

Reputation:

Place image behind div with textbox

I need help for placing an image behind the div (container_3_text).The image has to cover the whole div (container_3) that is behind the text div. I tried position relative and absolute but it does not work or maybe I'm doing it wrong. My image is from my Wordpress account so I don't write it in the link. Please help a student :) thanks

.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>

Upvotes: 1

Views: 82

Answers (4)

Ahmed Tag Amer
Ahmed Tag Amer

Reputation: 1422

Just use background-image: url(); and 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>

Upvotes: 1

codesayan
codesayan

Reputation: 1715

Make .container_3_text absolute, as per your html.

.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>

Upvotes: 1

user6144292
user6144292

Reputation: 163

try this

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

Upvotes: 1

shakogele
shakogele

Reputation: 399

You can use:

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

Upvotes: 1

Related Questions