Resizing bootstrap cards to match them - css

I'm using the card bootstrap parameters, but my differents card-img-top resizes differently. I'm searching for css in order to make them even but trying to maintain the same quality or similar.

Try this out:
.card-img-top {
height: 15vw;
object-fit: cover;
width: 100%;
}

Related

Alternative to object-fit with wkhtmltopdf

I am currently trying to export html pages to pdf using wkhtmltopdf, but the object-fit I use to force my images into a square doesn't work; the images end up stretched to fit the square box instead of being cropped properly.
I know for a fact that object-fit doesn't work with wkhtmltopdf, and I've been looking for workarounds (cf Object-fit: cover; alternative? ) but :
I cannot access the image directly since it's used in a template (for the background method)
I have no easy way to differentiate between horizontal or vertical images
here's the current snippet I have that doesn't work (works fine on the html though):
.class .img-box {
width: 44px;
height: 44px;
margin-right: 10px;
display: inline-block;
vertical-align: middle;
}
.class .img-box img {
width: 100%;
height: 100%;
object-fit: cover;
}
I'm at the point where I start getting a little upset by this, so if anyone knows about a working solution, I'd be glad to know about it. Thanks

"Background-image: cover" broken on mobile

I'm trying to make the image on my site to display 100% height but crop width as needed. On PC the site works as intented as can be seen below:
However when I check the site with my phone it displays the whole image distorting it.
HTML:
<header class="wide">
</header>
CSS:
body, html {
height: 100%;
}
.wide {
width: 100%;
height: 100%;
background-image: url('sebastian-unrau-42537-unsplash.jpg');
background-size: cover;
background-attachment: fixed;
background-position: center;
background-repeat: no-repeat;
}
#media (max-width: 1199.98px) {
.wide {
background-attachment: scroll;
background-position: initial;
}
}
The media query is mandatory as the image doesn't work at all if the background-image is fixed and centered.
Now if I remove "background-size: cover":
It's kind of closer what I'm after but not quite. Am i missing something?
My PC is running Chrome 66.0.3359.117 and my phone 65.0.3325.109
Ok I figured it out by accident. I was using an image from Unsplash.com and the the original resolution is 6000x4000. As I was making a Codepen project to post here I resized the image and wondered why it worked on codepen but not on my pc. Well it seems the resolution needs to be about 5500x3667 or smaller to work.
Maybe there is a limitation I did not know of but anyway got it working now. I didn't change anything else.
You could use this property :
background-size: x% y%;
The first value is the horizontal position and the second value is the vertical.
So you can try :
background-size: auto 100%;

Pure CSS - Header img resizes to fit smaller browsers but blows up and gets cut off with larger browsers

I've searched just about every string of words possible to try and find a solution to this issue and have had no luck. Here's the code I have for the header:
/* MAIN HEADER */
.header {
background-image: url(../images/kt-header2.jpg);
background-repeat: no-repeat;
background-size: 100%;
background-position: fixed;
background-size: cover;
margin: 0;
padding-top: 0em;
padding-bottom: 5em;
overflow: hidden;
width: 100%;
height: auto;
width: auto\9; /* ie8 */
}
This is what the header img looks like when the browser is smaller.
This is what it looks like when the browser is larger.
For all I know, this is a mess and the solution is obvious. I've been trying to piece things together with no previous knowledge of css, so I'm flying blind here.
I have linked a recreation of the code as a comment under the first comment on this post. Because I am a new user, I can't put more than 2 links in this post.
Did you try to add a set height to the header? If you add the set height, it won't be overcome by the other elements on a larger browser
I added: .header{height: 100px;) (used another image)
https://jsfiddle.net/toolbox3/8Lbdx2fm/

Resize image dynamically with CSS

I'm reading news on this page mostly on my mobile device:
link
The big banner right of the logo is not scaling properly on the mobile device.
So when you resize the window and make it smaller everything is resizing except the banner.
Im learning php, css and just wondering how this could be solved. Ive checked also on stackoverflow and find something like:
img {
max-width: 100%;
height: auto;
width: auto\9; /* ie8 */ }
I've tried this also in the dev. mode of google chrome but it desnt work.
Is this solvable with the provided data from the dev mode?
Code looks like:
<div style="position:relative;
width:728px; height:90px; z-index:10;
background-image: url(http://www.image.jpg);">
Based on your code, the banner is implemented as background image, not an IMG element. To make background image scaled so that it's entirely visible, use background-size: contain. So your user styles could be like this:
.site-header-banner > DIV {
background-size: contain;
background-repeat: no-repeat; // To disable repeating background image.
max-width: 100%;
}
You can use it as a background with the following properties:
background-repeat: no-repeat;
background-position: center center;
background-size: cover;
https://jsfiddle.net/alexndreazevedo/xe9tvkyr/
You can define a fixed size to DIV containing image background and change it by media query.

Responsive height for Background-Size Image CSS

I have a responsive background image with the following properties
background: url( '#{sitePath}/main_banner.png') center no-repeat;
max-width: 100%;
z-index: -10;
height: 475px;
background-size: contain;
The image needs to be able to scale down (as it does currently) but without a massive height (475px) for smaller devices. 100% min & standard height do not work and I want to avoid specifying individual heights for different media queries if I can help it.
Does anyone know how I can make this effectively responsive?
Thanks
You have put static height: 475px; If you want to have smaller height on smaller device try using media queries:
#media (max-width: size-that-you-want){
.class-name{
width: some-number;
}
}
This should work.

Resources