hhaarr
Feb 2 2021, 05:13 PM
Hello everyone
why does it work here
CODE
<divs>
<img src="pix.jpeg" alt="Eastern Port" class="A5">
</div>
but not here
CODE
<divs class="A5" >
<img src="pix.jpeg" alt="Eastern Port">
</div>
this is as far as it goes for the class in CSS
CODE
.A5 {
width: 50%;
}
Thanks for any help
CharlesEF
Feb 2 2021, 05:36 PM
Maybe because there is no < divs >, it should be < div>
hhaarr
Feb 2 2021, 05:42 PM
QUOTE(CharlesEF @ Feb 2 2021, 05:36 PM)
Maybe because there is no < divs >, it should be < div>
just a typo, same thing with Div
pandy
Feb 3 2021, 03:44 AM
No reason why it shouldn't work. Do you expect it to change the width of the image? It won't. It will change the width of the DIV. You can see that it does if you make the DIV visible by putting a border or background color on it.
If you want the image to fill the DIV, not matter what width the DIV is, you need to set the width of the image to 100%.
Christian J
Feb 3 2021, 07:43 AM
Also, image files have an intrinsic width (which is used if no width is specified for the IMG element), and if that width is wider than the container element, the image will spill out. By adding a border or background to the DIV you can check this.
This is a "lo-fi" version of our main content. To view the full version with more information, formatting and images, please
click here.