1

For some reason the code below works once, but if I change the height values for .Image, it stops working. The test image overflows instead of being hidden. Then the containing div won't resize no matter how often I try to change height.

    .Image{
        background-color:red;
        height:400px; 
        overflow:hidden;    
    }

 </style>

</head>
<body>
<div class="main">
    <div class="Image">
        <img "src="images/test.jpg" alt="test">
         </div> 
</div>
</body>
</html>
7
  • 2
    can you give a working example? because overflow and height should always work Commented Jan 5, 2014 at 9:08
  • 3
    Please do provide an example jsfiddle of what won't work, I tested your code and changing the image's height using CSS dosen't seem to reproduce your issue. I would reccomend removing the quotation mark preceding the src, but I assume this was not in your initial code as it stops the image rendering altogether. Commented Jan 5, 2014 at 9:33
  • 1
    it is working check on fiddle Commented Jan 5, 2014 at 10:10
  • Okay..so it looks like I was using the wrong comment tags? In creating a fiddle I stumbled across a comment I had written in the original code next to the .Image height property. I used <!-- --> instead of /* */. If you add <!--COMMENT --> to rrugby's fiddle, it reproduces the problem I was seeing, except sometimes it would work at first, then stop. So is <!-- --> not allowed in internal style sheets?? Commented Jan 5, 2014 at 16:26
  • You might not fully understand CSS - <!-- --> is not a valid comment in CSS. Comments in CSS are /* */ - please Edit your question to include a full code example with jsfiddle that consistently fails. Voting to close. Commented Jan 5, 2014 at 16:51

1 Answer 1

1

the reason why is doesn't work is because you have an error in your code at img

<img "src="images/test.jpg" alt="test">

your error is ->

<img "src="...">

it should be ->

<img src="...">

with out the extra quote

so your code should look like this

   .Image{
        background-color:red;
        height:400px; 
        overflow:hidden;    
    }

 </style>

</head>
<body>
    <div class="main">
    <div class="Image">
        <img src="images/test.jpg" alt="test">
    </div> 
    </div>
</body>
</html>
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.