0

I want my header h1 to resize automatically with the browser size which is inline with an image so that it won't take most of the screen size when viewed in smalls screen and will leave some space for the image. Also please do take care of header h3 i.e it should also take up required space.

Code :

You can find the code on jsfiddle here

<body>

  <div id="main_wrapper">
    <header>
      <div id="header_title">
        <h1>Lorem Ipsum dolor sit amet facilisis ut </h1>
        <h3>"Vivamus sed libero nec mauris pulvinar facilisis ut non sem."</h3>
      </div>
      <aside id="header_photo">
        <img src="http://3.bp.blogspot.com/-hSDYcX9cd5w/UZnDC0Z27PI/AAAAAAAAAGg/WmWDp_cZfw4/s1600/lorem-ipsum-dolor-sit-amet-5.png" alt="Placeholder" class="floatingimage" title="Placeholder" />
      </aside>
    </header>
  </div>
</body>


body {
  background-size: 120%;
  font-family: 'MyFont', Arial, sans-serif;
  color: #181818;
}

#main_wrapper {
  width: 80%;
  margin: auto;
}

header {
  width: 100%;
  height: auto;
  margin: 0;
  padding: 0 0 40%;
}

#header_title {
  text-align: center;
  max-width: 78%;
}

#header_photo {
  /*display: none;*/
  margin: 0;
  padding: 0;
  max-width: 20%;
  height: auto;
  float: right;
}

.floatingimage {
  position: relative;
  display: none;
}

.wh100 {
  width: 100px;
  height: 100px;
}

@media all and (max-width:1024px) {
  #main_wrapper {
    width: auto;
    margin: none;
  }
  #header_title,
  #header_photo img {
    margin: 0;
    padding: 0;
    display: inline!important;
    vertical-align: middle!important;
  }
  #header_title {
    max-width: 78%;
    position: relative;
    float: left;
  }
  #header_photo {
    margin-top: 4%;
    max-width: 20%;
    position: relative;
    float: right;
  }
  #header_photo img {
    position: relative;
    max-width: 100%;
    height: auto;
  }
}

NOTE: I'm using Firefox 53.0.3(32-bit)

3
  • are you looking for something like this? jsfiddle.net/91sung8y/3 Commented Jun 12, 2017 at 17:37
  • Thanks man that works. Commented Jun 12, 2017 at 17:39
  • 1
    You're welcome. Wasn't sure if that's what you were going for or not. Submitted as an answer. Commented Jun 12, 2017 at 17:41

1 Answer 1

1

If you want the font size to scale with the width of the browser, use vw units for the font-size

body {
  background-size: 120%;
  font-family: 'MyFont', Arial, sans-serif;
  color: #181818;
}

#main_wrapper {
  width: 80%;
  margin: auto;
}

header {
  width: 100%;
  height: auto;
  margin: 0;
  padding: 0 0 40%;
  font-size: 3vw;
}

#header_title {
  text-align: center;
  max-width: 78%;
}

#header_photo {
  /*display: none;*/
  margin: 0;
  padding: 0;
  max-width: 20%;
  height: auto;
  float: right;
}

.floatingimage {
  position: relative;
  display: none;
}

.wh100 {
  width: 100px;
  height: 100px;
}

@media all and (max-width:1024px) {
  #main_wrapper {
    width: auto;
    margin: none;
  }
  #header_title,
  #header_photo img {
    margin: 0;
    padding: 0;
    display: inline!important;
    vertical-align: middle!important;
  }
  #header_title {
    max-width: 78%;
    position: relative;
    float: left;
  }
  #header_photo {
    margin-top: 4%;
    max-width: 20%;
    position: relative;
    float: right;
  }
  #header_photo img {
    position: relative;
    max-width: 100%;
    height: auto;
  }
}
<body>

  <div id="main_wrapper">
    <header>
      <div id="header_title">
        <h1>Lorem Ipsum dolor sit amet facilisis ut </h1>
        <h3>"Vivamus sed libero nec mauris pulvinar facilisis ut non sem."</h3>
      </div>
      <aside id="header_photo">
        <img src="http://3.bp.blogspot.com/-hSDYcX9cd5w/UZnDC0Z27PI/AAAAAAAAAGg/WmWDp_cZfw4/s1600/lorem-ipsum-dolor-sit-amet-5.png" alt="Placeholder" class="floatingimage" title="Placeholder" />
      </aside>
    </header>
  </div>
</body>

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.