How to set height and width of an image in html?
But In My view Image looks like this
Here is html code:
HTML
<div class="imgslides">
<div class="slide">
<img src="uploads/pexels-pixabay-415100.jpg" />
</div>
<div class="slide">
<img src="uploads/eric-ward-ISg37AI2A-s-unsplash.jpg" />
</div>
<div class="slide">
<img src="uploads/pexels-helena-lopes-745045.jpg" />
</div>
<div class="slide">
<img src="uploads/pexels-pixabay-38284.jpg" />
</div>
<div class="slide">
<img src="uploads/pexels-visionpic-net-341378.jpg" />
</div>
</div>
Below is the CSS for the html:
CSS
.sliders
{
width:700px;
height: 400px;
overflow: hidden;
}
.show
{
position: absolute;
top: 50%;
left: 50%;
transform: translate(-50%,-50%);
}
.imgslides
{
width: 500%;
height: 100%;
display: flex;
}
Any Suggestion?
You need to set a height and width for the image if you are uploading it in a size that is bigger than you want to show. Be careful, you have the slide class in the html and in the css it says sliders. You could set the size in the outer div and have the image class be:
.imgclass
{
width: 100%;
height: 100%;
}
Just remember it is best practice to serve smaller images for smaller screens
Related
Here is a sample image of the layout I am trying to achieve with HTML and CSS:
From what the gallery looks like,
the images are placed in a row
each row fills the width of the container
each image fills the height of the row
The height of each row looks to be slightly different (e.g. min-height: 300px; max-height: 600px;) to accomadate for the different aspect ratios of the image.
I'm trying to build this layout with html and css flexbox, but haven't really gotten too far with it:
.gallery-container {
display: block;
margin: 0 auto;
width: 50%;
}
.gallery-row {
display: flex;
min-height: 300px;
max-height: 500px;
}
.gallery-img {
position: relative;
flex-grow: 1;
max-width: 33.3%;
}
.gallery-img img {
height: 100%;
}
<div class="gallery-container">
<div class="gallery-row">
<div class="gallery-img">
<img src="https://picsum.photos/200/300"/>
</div>
<div class="gallery-img">
<img src="https://picsum.photos/300/200"/>
</div>
<div class="gallery-img">
<img src="https://picsum.photos/400/200"/>
</div>
</div>
<div class="gallery-row">
<div class="gallery-img">
<img src="https://picsum.photos/400/300"/>
</div>
<div class="gallery-img">
<img src="https://picsum.photos/100/200"/>
</div>
<div class="gallery-img">
<img src="https://picsum.photos/300/200"/>
</div>
</div>
</div>
I have a simple slick carousel
<div class="your-class">
<div class="slider">
<img src="assets/img/train.jpg" alt="">
</div>
<div class="slider">
<img src="assets/img/plane.jpg" alt="">
</div>
<div class="slider">
<img src="assets/img/truck.jpg" alt="">
</div>
<div class="slider">
<img src="assets/img/ship.jpg" alt="">
</div>
</div>
.slick-track {
display: flex !important;
}
.slick-slide {
height: inherit !important;
display: flex !important;
justify-content: center;
}
.slider {
max-height: 400px;
}
.slider img {
width: 100%;
height: auto;
}
As you can see I want to change the size of slider to 400px but the image looks flattened. If I remove slider height then the picture is too big with vertical scroll,I need to make img's height be approx 400px. Can you please help what I can do ?
I'm working in movie production website and trying to display movies images in equal size but i have different sizes of images and i need to place image in div like full size i.e all four corners should be zoomed in. Please help.
MY CODE
<div id="movies-images">
<img class="img-fluid" src="images/a4.jpg">
</div>
CSS :
#movies-images{
width: 100%;
height: 100%;
}
I want images to equal in width and height.
Try this:
.img-box {
display: flex;
justify-content: space-between;
}
.movies-images {
width: 33%;
height: auto;
}
.movies-images img {
width: 100%;
display: block;
}
<div class="img-box">
<div class="movies-images">
<img class="img-fluid" src="http://lorempixel.com/800/600/">
</div>
<div class="movies-images">
<img class="img-fluid" src="http://lorempixel.com/800/600/">
</div>
<div class="movies-images">
<img class="img-fluid" src="http://lorempixel.com/800/600/">
</div>
</div>
I'd like to know, is it possible to change img dimensions while preserving its responsiveness on browser resize? Applying height and width doesn't work.
.wrap1 {
position: relative;
overflow: hidden;
}
.img1 {
height: auto;
width: 100%;
}
<div class="container-fluid">
<div class="row">
<div class="wrap1">
<img class="img1" src="http://lorempixel.com/600/400" alt="">
</div>
</div>
</div>
I want to display one image over another. It have to be responsive, with cutting image's edges if i resize. (see the pictures. i can't directly embedded images yet, without 10 reputation). How can i do that?
Here's the code:
<div class="content">
<div class="content-item_1">
<img class="img1" src="photo/image1.png" />
text1. text text
</div>
<div class="content-item_2">
<img class="img2" src="photo/image1.png" />
text2. text text
</div>
</div>
Something like this https://jsfiddle.net/5woswyxc/2/
but image 2 have to be slighty over image 1, if it resize.
and when size is reduced - text 1 must move on the top on image 2.
(image1 is moved to bottom)
resized layout
try this:
<body>
<div class="content">
<div class="parent">
<img class="image1" src="http://openclipart.org/image/300px/svg_to_png/4112/Clue_Simple_Clouds.png" />
<img class="image2" src="http://openclipart.org/image/300px/svg_to_png/4112/Clue_Simple_Clouds.png" />
</div>
</div>
<style>
.parent {
position: relative;
top: 0;
left: 0;
background-color: blue;
width: 450px;
height: 320px;
overflow: hidden;
}
.image1 {
position: relative;
top: 0;
left: 0;
}
.image2 {
position: absolute;
top: 30px;
left: 70px;
}
</style>
</body>