Solution 1 :

You needd to use media query: check this link to understand it
https://www.w3schools.com/css/css_rwd_mediaqueries.asp

Try this code:

.banner {
  position: relative;
}

.banner img {
  display: inline-block;
  width: 100%;
}

.banner-text {
  position: absolute;
  width: 100%;
  top: 20%;  
  text-align: center;
  color: white;
  font-weight: bold;
  letter-spacing: 10px;
  font-size: 60px;
}

@media only screen and (max-width: 600px) {
  .banner-text {
    font-size: 40px;
  }
}

@media only screen and (max-width: 400px) {
  .banner-text {
    font-size: 20px;
  }
}
<div class="banner">
  <img src="images/banner.jpg" width="100%;">
  <div class="banner-text">
    <p>HOŞGELDİNİZ!</p>
  </div>
</div>

Problem :

enter image description here
enter image description here I am trying to attach this article to the photo as responsive. i tried something but I couldn’t :/

HTML

        <div class="banner">
            <img src="images/banner.jpg" width="100%;">
            <div class="banner-text">
                <p>HOŞGELDİNİZ!</p>
            </div>
        </div>

CSS

.banner img {
    display: inline;
}

.banner {
    position: relative;
    display: inline-block;
}

.banner-text {
    position: absolute;
    top: 20%;
    left: 50%;
    transform: translate( -50%, -50% );
    text-align: center;
    color: white;
    font-weight: bold;
    letter-spacing: 10px;
    font-size: 60px;
}

Comments

Comment posted by Marik Ishtar

what do you mean by ‘as responsive’? you want to keep it in the center ?

Comment posted by Emirhan

Yes. on mobile devices, text should be on the photo. It shouldn’t be too big, too small or else.

Comment posted by imgur.com/ag7hLVP

text is working but photo broke

Comment posted by Marik Ishtar

I updated the code, try it. just remove the

By

Leave a Reply

Your email address will not be published. Required fields are marked *