I need to use a dialog box to display a relatively large set of images to the user.
I want this image to be scaled when it exceeds the size of the dialog, but in any case no scrollbars should appear. And the image should be centered both horizontally and vertically in the main section of the dialog.
In normal html, I know that this can be set in two ways.
.img {
max-height: 100%;
max-width: 100%;
}
or
.img {
object-fit: scale-down;
}
However, since Quasar's Dialog Plugin doesn't seem to have a defined size, max-height doesn't have an effect.
You can reproduce this problem by reducing the height of the output window. When you drag the height to very small, a scroll bar appears on the dialog box.
How do I adjust it to achieve what I need?
The The code that I tried is here:
https://codepen.io/sshxmz/pen/vYryeWR
Related
https://jsfiddle.net/ug4u48pr/3/
I'm trying to build a simple app to put on a webpage with the intention to be accessed by mobile devices.
Because mobile devices tend to have a variety of resolutions, I figured I'd try to make the header/footer sections remain as consistent as possible by making them have heights of 20% with the body section having a height of 60%.
The problem is that I can't seem to fit the image within the constraints of the relative height of the header.
I've looked around and failed with an assortment of things such as...
img {max-height: 100%; max-width: 100%;}
img {display: block; overflow: visible/hidden;}
img {width: 100%; height: auto;}
img {height: 70px;}
The solution to my problem has to work dynamically as the window is resized.
I've managed to make the image properly scale by setting it as a "background". Before as an , it was too large/small and didn't fit the header. Now it does, but ruins the positioning of the title.
The "Application Title" should be centered vertically/horizontally with respect to the remaining width of the header, with its left edge of the cell touching the right edge of the image.
I figure there is a simple and straight forward solution, but I just can't seem to find it.
I have a gallery (responsiveslides.js) that is launched within a jquery mobile popup that overlays the window. The desired look is to have the gallery scale based on the browser window.
Here is a stripped down working example of my setup and issue: https://jsfiddle.net/02ds2trp/
What I'm trying to accomplish is to have the popup div height match the scaled image. The blue background is ok on the sides of the image but I don't want it on the bottom/top. ie. the orange border should be tight to the image. Also the popup div shouldn't grow more then 70% of the screen.
Right now I have .popupGalleryBannerDIV with height:70% but that is growing it too big, removing that makes the image gallery have no height.
.popupGalleryBannerDIV {
position: fixed;
width: 100%;
background: #2795EE;
top: 15%;
left: 0px;
height: 70%; /* how to I make this dynamic? */
max-height: 70%;
}
Note: I've been playing with this for a week so some css markup on fiddle might be from failed attempts.
I'm having trouble figuring out how to make this work any help would be appreciated.
Edit:
Add some picture to help understand what I'm trying to do.
View post on imgur.com
Part of the problem, is that your slide is using a background image which has no default height/width on it's own. It's the content that dictates how much space should be filled up.
My suggestion is to use an tag instead or have some js function that will appropriately size the viewport height to match the image's ratio based on the viewport width.
This is how I ended up coding the size change:
function gallerySize() {
//set height of content to 70%
$('.popupGalleryBannerDIV').css("height", "70%");
//check img size compaired to it, of large set image height to height of content
var imgHeight = $('.popupGalleryBannerDIV').find('img').height();
//else if height is smaller set conect to height of img
if (imgHeight < $('.popupGalleryBannerDIV').height()){
$('.popupGalleryBannerDIV').css("height", imgHeight);
}
}
I'm trying to set up a fluid column layout for a site I'm working on. I'd like to do this without javascript, but it's looking like that might end up being the easiest option. Regardless, anyone know how to get this done with CSS?
Both columns need to fill the browser height. The left column contains an image with an aspect ratio of 2:3, with height: 100% and width: auto, so the left column's width will change depending on how tall the browser is. The right column needs to fill the remaining space.
I saw a trick using float:left and overflow: hidden that's working great, except the divs do not resize themselves correctly when the browser window is resized.
Here's a simplified fiddle to demonstrate the problem, with the CSS below:
.left-column {
float: left;
}
.left-column img {
height: 100%;
display: block;
width: auto;
}
.right-column {
box-sizing: border-box;
padding: 20px;
overflow-x: hidden;
overflow-y: scroll;
}
.left-column, .right-column {
height: 100%;
}
https://jsfiddle.net/v7unnhnc/2/
It seems like .left-column doesn't resize itself automatically. Any ideas?
basically your code works ok. You may add display:inline-block to your left column and you will see the img container adapt when resizing vertically, however the text won't flow properly this time.
The problem (if a problem) is that the width of your container (left one).. the one with your width:auto (and you don't really need to add it to your css as your image will set the width of the container when overflow is hidden.. when floating) won't understand the resize of the img without reloading the page even if you visually can see it.
But it's important to know as many web developers these days are too much focused into (imho) making a responsive design while resizing the window that GOAL is not that. The main goal is your web to adapt to whatever window size your users (or future users) have at the moment they load your web. And your code is right on that.
Just people like us may go into a web and start resizing manually the window to check the responsiveness.. and even then, the vast mayoritie of us with just check it resizing on the x-axis.
The chances you have to get someone notice your web not working ok when resizing the window (y-axis) is... well, I hope you have SOO many pepople noticing. that will mean you have a lot of visitors.
I'm building a portfolio in indexhibit where all pages of images use a a horizontal div to scroll through the images.
I didn't like the way the images were reduced in quality and wanted them to appear as large as the visitors screen would allow (without it going over), so I made them responsive (height: 90%; width: auto;).
The trouble is: the horizontal container div has a width that is the size of all of the original images (as per the indexhibit formatting is built to) - leaving a large white space to the right of all the images. This is because the images are downsized to fit the screen responsively - so I guess if you had a big enough screen size these images would actually
If I make the container div width: auto, it obviously splits the images onto the next line.
Is there something I can do with CSS to solve this issue - I'm not confident going in and modifying core files with this cms.
Thanks
Mike Chalmers
I played around with the way the images were displaying and inline-block solved it. The container needs some changes to get it to display horizontally. Here's the basic code:
#img-container {
overflow-x: scroll;
overflow-y: hidden;
white-space:nowrap;
}
.img-div {
display: inline-block;
}
I have an image in the header of my website. I'd like to use a CSS property to make it stretch across the width of the browser, so that it reacts to the user adjusting the browser window size, and so that the vertical axis of the image is scaled accordingly. Is this actually something that can be done?
Percentages will keep an image the whole width, and will update the image on browser resizing.
If you want the image to always be stretch, you can use:
img {
width:100%;
}
However, that can easily make the image look like total crap. A safer way might be:
img {
max-width:100%;
}
Either way will get the image changing sizes with browser resizing. However, the second won't stretch the image past it's natural size, so it doesn't look deformed.
You can set the width and height properties to percentages (for example, a width of 100% would cause the image to stretch across your page). This can be done using CSS.
CSS can certainly stretch an image (or, at least, I've used it to do so in Firefox at the folowing url: http://www.davidrhysthomas.co.uk/mindez/borked.html):
img {height: 100%;
width: 100%;
min-height: 600px;
min-width: 800px;
}
for example.
But...I think for it to react to the viewport resizing that JS would be probably your better-friend.
Here, give this a go, just apply this CSS style to the element that contains the image. In this example the image is on the background of the page body:
body
{
margin: 0;
padding: 0;
width: 100%;
background: url(images/YOUR-IMAGE.JPG) no-repeat left top;
background-size: 100%;
}
This will maximise your image across the element. Resizing the window will scale the image to fit the browsers new window size