Image oveflowing container due to h2 being above itHow do you keep parents of floated elements from collapsing?Vertically align text next to an image?How do I give text or an image a transparent background using CSS?Floating elements within a div, floats outside of div. Why?How do I auto-resize an image to fit a 'div' container?How to set the margin or padding as percentage of height of parent container?How to define height of a container by an element within that containerCenter Oversized Image in DivHTML table with 100% width, with vertical scroll inside tbodyVertically align an image inside a div with responsive height

Subtables with equal width?

Does an ice chest packed full of frozen food need ice?

Payment instructions from HomeAway look fishy to me

Avoiding cliches when writing gods

Was the Tamarian language in "Darmok" inspired by Jack Vance's "The Asutra"?

How to retract an idea already pitched to an employer?

Why does the Schrödinger equation work so well for the Hydrogen atom despite the relativistic boundary at the nucleus?

Is it recommended against to open-source the code of a webapp?

Do simulator games use a realistic trajectory to get into orbit?

PL/SQL function to receive a number and return its binary format

Are "living" organ banks practical?

Select items in a list that contain criteria #2

Why is the relationship between frequency and pitch exponential?

Can you really not move between grapples/shoves?

Do any instruments not produce overtones?

What can plausibly explain many of my very long and low-tech bridges?

Strange symbol for two functions

Does the growth of home value benefit from compound interest?

When writing an error prompt, should we end the sentence with a exclamation mark or a dot?

Trapping Rain Water

How to translate “Me doing X” like in online posts?

Movie about a boy who was born old and grew young

What do we gain with higher order logics?

Why don’t airliners have temporary liveries?



Image oveflowing container due to h2 being above it


How do you keep parents of floated elements from collapsing?Vertically align text next to an image?How do I give text or an image a transparent background using CSS?Floating elements within a div, floats outside of div. Why?How do I auto-resize an image to fit a 'div' container?How to set the margin or padding as percentage of height of parent container?How to define height of a container by an element within that containerCenter Oversized Image in DivHTML table with 100% width, with vertical scroll inside tbodyVertically align an image inside a div with responsive height






.everyoneloves__top-leaderboard:empty,.everyoneloves__mid-leaderboard:empty,.everyoneloves__bot-mid-leaderboard:empty height:90px;width:728px;box-sizing:border-box;








0















I faced the problem with image overflowing its container when I use height:100%; for the image itself. Here is the code:



<div>
<h2>Website</h2>
<img src="./images/reptiles.jpg" alt="" >
</div>

CSS
div
height:480px;


div>img
width:100%;
height:100%;










share|improve this question






















  • 100% means 480px so the total height will be 480px + height of h2 thus the overflow

    – Temani Afif
    Mar 24 at 15:38











  • @TemaniAfif, than k you for your comment and how can I solve img overflow. Only, overflow:hidden or there is a better solution?

    – mirzhal
    Mar 24 at 15:41

















0















I faced the problem with image overflowing its container when I use height:100%; for the image itself. Here is the code:



<div>
<h2>Website</h2>
<img src="./images/reptiles.jpg" alt="" >
</div>

CSS
div
height:480px;


div>img
width:100%;
height:100%;










share|improve this question






















  • 100% means 480px so the total height will be 480px + height of h2 thus the overflow

    – Temani Afif
    Mar 24 at 15:38











  • @TemaniAfif, than k you for your comment and how can I solve img overflow. Only, overflow:hidden or there is a better solution?

    – mirzhal
    Mar 24 at 15:41













0












0








0








I faced the problem with image overflowing its container when I use height:100%; for the image itself. Here is the code:



<div>
<h2>Website</h2>
<img src="./images/reptiles.jpg" alt="" >
</div>

CSS
div
height:480px;


div>img
width:100%;
height:100%;










share|improve this question














I faced the problem with image overflowing its container when I use height:100%; for the image itself. Here is the code:



<div>
<h2>Website</h2>
<img src="./images/reptiles.jpg" alt="" >
</div>

CSS
div
height:480px;


div>img
width:100%;
height:100%;







html css






share|improve this question













share|improve this question











share|improve this question




share|improve this question










asked Mar 24 at 15:32









mirzhalmirzhal

8919




8919












  • 100% means 480px so the total height will be 480px + height of h2 thus the overflow

    – Temani Afif
    Mar 24 at 15:38











  • @TemaniAfif, than k you for your comment and how can I solve img overflow. Only, overflow:hidden or there is a better solution?

    – mirzhal
    Mar 24 at 15:41

















  • 100% means 480px so the total height will be 480px + height of h2 thus the overflow

    – Temani Afif
    Mar 24 at 15:38











  • @TemaniAfif, than k you for your comment and how can I solve img overflow. Only, overflow:hidden or there is a better solution?

    – mirzhal
    Mar 24 at 15:41
















100% means 480px so the total height will be 480px + height of h2 thus the overflow

– Temani Afif
Mar 24 at 15:38





100% means 480px so the total height will be 480px + height of h2 thus the overflow

– Temani Afif
Mar 24 at 15:38













@TemaniAfif, than k you for your comment and how can I solve img overflow. Only, overflow:hidden or there is a better solution?

– mirzhal
Mar 24 at 15:41





@TemaniAfif, than k you for your comment and how can I solve img overflow. Only, overflow:hidden or there is a better solution?

– mirzhal
Mar 24 at 15:41












2 Answers
2






active

oldest

votes


















0














try this html



<div>
<h2>Website</h2>
<figure>
<img src="https://www.thalesgroup.com/sites/default/files/styles/article_card/public/database/d7/e-services_modified_1.jpg?itok=DkaYx8h8" alt="" />
</figure>

</div>


fiddle link is https://jsfiddle.net/7vxnw95o/1/






share|improve this answer






























    0














    Try below code, i hope it'll help you out. Thanks






    .parent-div
    display: flex;
    flex-direction: column;
    height:480px;


    div>img
    width:100%;
    height:100%;

    <div class="parent-div">
    <h2>Website</h2>
    <div>
    <img src="https://images.pexels.com/photos/1020315/pexels-photo-1020315.jpeg" alt="" >
    </div>
    </div>








    share|improve this answer























      Your Answer






      StackExchange.ifUsing("editor", function ()
      StackExchange.using("externalEditor", function ()
      StackExchange.using("snippets", function ()
      StackExchange.snippets.init();
      );
      );
      , "code-snippets");

      StackExchange.ready(function()
      var channelOptions =
      tags: "".split(" "),
      id: "1"
      ;
      initTagRenderer("".split(" "), "".split(" "), channelOptions);

      StackExchange.using("externalEditor", function()
      // Have to fire editor after snippets, if snippets enabled
      if (StackExchange.settings.snippets.snippetsEnabled)
      StackExchange.using("snippets", function()
      createEditor();
      );

      else
      createEditor();

      );

      function createEditor()
      StackExchange.prepareEditor(
      heartbeatType: 'answer',
      autoActivateHeartbeat: false,
      convertImagesToLinks: true,
      noModals: true,
      showLowRepImageUploadWarning: true,
      reputationToPostImages: 10,
      bindNavPrevention: true,
      postfix: "",
      imageUploader:
      brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
      contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
      allowUrls: true
      ,
      onDemand: true,
      discardSelector: ".discard-answer"
      ,immediatelyShowMarkdownHelp:true
      );



      );













      draft saved

      draft discarded


















      StackExchange.ready(
      function ()
      StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f55325427%2fimage-oveflowing-container-due-to-h2-being-above-it%23new-answer', 'question_page');

      );

      Post as a guest















      Required, but never shown

























      2 Answers
      2






      active

      oldest

      votes








      2 Answers
      2






      active

      oldest

      votes









      active

      oldest

      votes






      active

      oldest

      votes









      0














      try this html



      <div>
      <h2>Website</h2>
      <figure>
      <img src="https://www.thalesgroup.com/sites/default/files/styles/article_card/public/database/d7/e-services_modified_1.jpg?itok=DkaYx8h8" alt="" />
      </figure>

      </div>


      fiddle link is https://jsfiddle.net/7vxnw95o/1/






      share|improve this answer



























        0














        try this html



        <div>
        <h2>Website</h2>
        <figure>
        <img src="https://www.thalesgroup.com/sites/default/files/styles/article_card/public/database/d7/e-services_modified_1.jpg?itok=DkaYx8h8" alt="" />
        </figure>

        </div>


        fiddle link is https://jsfiddle.net/7vxnw95o/1/






        share|improve this answer

























          0












          0








          0







          try this html



          <div>
          <h2>Website</h2>
          <figure>
          <img src="https://www.thalesgroup.com/sites/default/files/styles/article_card/public/database/d7/e-services_modified_1.jpg?itok=DkaYx8h8" alt="" />
          </figure>

          </div>


          fiddle link is https://jsfiddle.net/7vxnw95o/1/






          share|improve this answer













          try this html



          <div>
          <h2>Website</h2>
          <figure>
          <img src="https://www.thalesgroup.com/sites/default/files/styles/article_card/public/database/d7/e-services_modified_1.jpg?itok=DkaYx8h8" alt="" />
          </figure>

          </div>


          fiddle link is https://jsfiddle.net/7vxnw95o/1/







          share|improve this answer












          share|improve this answer



          share|improve this answer










          answered Mar 24 at 16:04









          Hammad tariqHammad tariq

          1299




          1299























              0














              Try below code, i hope it'll help you out. Thanks






              .parent-div
              display: flex;
              flex-direction: column;
              height:480px;


              div>img
              width:100%;
              height:100%;

              <div class="parent-div">
              <h2>Website</h2>
              <div>
              <img src="https://images.pexels.com/photos/1020315/pexels-photo-1020315.jpeg" alt="" >
              </div>
              </div>








              share|improve this answer



























                0














                Try below code, i hope it'll help you out. Thanks






                .parent-div
                display: flex;
                flex-direction: column;
                height:480px;


                div>img
                width:100%;
                height:100%;

                <div class="parent-div">
                <h2>Website</h2>
                <div>
                <img src="https://images.pexels.com/photos/1020315/pexels-photo-1020315.jpeg" alt="" >
                </div>
                </div>








                share|improve this answer

























                  0












                  0








                  0







                  Try below code, i hope it'll help you out. Thanks






                  .parent-div
                  display: flex;
                  flex-direction: column;
                  height:480px;


                  div>img
                  width:100%;
                  height:100%;

                  <div class="parent-div">
                  <h2>Website</h2>
                  <div>
                  <img src="https://images.pexels.com/photos/1020315/pexels-photo-1020315.jpeg" alt="" >
                  </div>
                  </div>








                  share|improve this answer













                  Try below code, i hope it'll help you out. Thanks






                  .parent-div
                  display: flex;
                  flex-direction: column;
                  height:480px;


                  div>img
                  width:100%;
                  height:100%;

                  <div class="parent-div">
                  <h2>Website</h2>
                  <div>
                  <img src="https://images.pexels.com/photos/1020315/pexels-photo-1020315.jpeg" alt="" >
                  </div>
                  </div>








                  .parent-div
                  display: flex;
                  flex-direction: column;
                  height:480px;


                  div>img
                  width:100%;
                  height:100%;

                  <div class="parent-div">
                  <h2>Website</h2>
                  <div>
                  <img src="https://images.pexels.com/photos/1020315/pexels-photo-1020315.jpeg" alt="" >
                  </div>
                  </div>





                  .parent-div
                  display: flex;
                  flex-direction: column;
                  height:480px;


                  div>img
                  width:100%;
                  height:100%;

                  <div class="parent-div">
                  <h2>Website</h2>
                  <div>
                  <img src="https://images.pexels.com/photos/1020315/pexels-photo-1020315.jpeg" alt="" >
                  </div>
                  </div>






                  share|improve this answer












                  share|improve this answer



                  share|improve this answer










                  answered Mar 24 at 16:18









                  Hassan SiddiquiHassan Siddiqui

                  1,9141715




                  1,9141715



























                      draft saved

                      draft discarded
















































                      Thanks for contributing an answer to Stack Overflow!


                      • Please be sure to answer the question. Provide details and share your research!

                      But avoid


                      • Asking for help, clarification, or responding to other answers.

                      • Making statements based on opinion; back them up with references or personal experience.

                      To learn more, see our tips on writing great answers.




                      draft saved


                      draft discarded














                      StackExchange.ready(
                      function ()
                      StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f55325427%2fimage-oveflowing-container-due-to-h2-being-above-it%23new-answer', 'question_page');

                      );

                      Post as a guest















                      Required, but never shown





















































                      Required, but never shown














                      Required, but never shown












                      Required, but never shown







                      Required, but never shown

































                      Required, but never shown














                      Required, but never shown












                      Required, but never shown







                      Required, but never shown







                      Popular posts from this blog

                      Kamusi Yaliyomo Aina za kamusi | Muundo wa kamusi | Faida za kamusi | Dhima ya picha katika kamusi | Marejeo | Tazama pia | Viungo vya nje | UrambazajiKuhusu kamusiGo-SwahiliWiki-KamusiKamusi ya Kiswahili na Kiingerezakuihariri na kuongeza habari

                      Swift 4 - func physicsWorld not invoked on collision? The Next CEO of Stack OverflowHow to call Objective-C code from Swift#ifdef replacement in the Swift language@selector() in Swift?#pragma mark in Swift?Swift for loop: for index, element in array?dispatch_after - GCD in Swift?Swift Beta performance: sorting arraysSplit a String into an array in Swift?The use of Swift 3 @objc inference in Swift 4 mode is deprecated?How to optimize UITableViewCell, because my UITableView lags

                      Access current req object everywhere in Node.js ExpressWhy are global variables considered bad practice? (node.js)Using req & res across functionsHow do I get the path to the current script with Node.js?What is Node.js' Connect, Express and “middleware”?Node.js w/ express error handling in callbackHow to access the GET parameters after “?” in Express?Modify Node.js req object parametersAccess “app” variable inside of ExpressJS/ConnectJS middleware?Node.js Express app - request objectAngular Http Module considered middleware?Session variables in ExpressJSAdd properties to the req object in expressjs with Typescript