Click here to Skip to main content
16,021,432 members
Please Sign up or sign in to vote.
1.00/5 (1 vote)
See more:
html coding
<section class="head-image">
	<figure>
		<img src="pictures/listen.jpg">
		<figcaption>Start Listening</figcaption>
	</figure>
	</section>


css coding

head-image img{
	width:2000px;
	height:1000px
	
}


What I have tried:

when i tried to insert an image to the middle of the then it was coming with very big size and getting over flow i just tried the overflow attribute but it didnt worked when iam using the width and height to control the image size the values are taking too high like 1500px and 2000px and also i cant align the image please help me if any one know the solution
Posted
Updated 28-Apr-21 22:32pm

You can control it with the img tag's attributes: HTML img tag[^]
 
Share this answer
 
To explain this to you: the image size you see is that size of the actual image and if it came from a camera, for example, even at only 12 MPixels it's 3000x4000 pixels in size and much bigger than your screen.

You need to use styles for this. Simple ones, like height and width, but there are also some very much more interesting ones.

In all cases, you must scale your images to fit the screen area where you wish them to be confined.
 
Share this answer
 
Your CSS specifies that the image should be 2000px wide and 1000px high.

If you don't want it to overflow, you have several options. The simplest is:
CSS
head-image img{
    max-width: 100%;
    height: auto;
}
If you know the aspect ratio of the image, you may also want to specify the new aspect-ratio property[^] so that your content doesn't shift after the image has downloaded.

There's also the object-fit property, which works everywhere except Internet Explorer:
object-fit - CSS: Cascading Style Sheets | MDN[^]
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900