How to Use CSS 'Resize' to Resize an Element to a Height/Width Less Than Initial Height/Width on Chrome

How can I use CSS `resize` to resize an element to a height/width less than initial height/width on Chrome?

I'm gonna say no(t without javascript).

Custom CSS to allow chrome textarea resize smaller than initial state?

The fact you cannot resize a textarea under its initial dimensions is
reported as a bug
(https://code.google.com/p/chromium/issues/detail?id=94583)

Using CSS to resize a div to a dimension smaller than its current width and height

The question is a little vague, can't you just make the panel a LayoutPanel?

Get/set the height and width with the Style methods of the DOM client package. Specifically, getHeight(), setHeight(), getWidth(), and setWidth().

div style=resize:both can not shrink in chrome (but it works in firefox)

I did some testing and it seems the content makes it impossible to resize down in chrome. I've updated your case to this

<div style='overflow:auto;resize:both;border:1px solid orange; min-height: 10px;'>
<div style='background-color:#eee;width:400px;max-height:300px; height:100%;'>
</div>
</div>

And it seems to work now: http://jsfiddle.net/4w7zd/7/

Not sure if this is an option for you, but it might point you in the right direction.

How to resize an image to fit in the browser window?

Update 2018-04-11

Here's a Javascript-less, CSS-only solution. The image will dynamically be centered and resized to fit the window.

<html>
<head>
<style>
* {
margin: 0;
padding: 0;
}
.imgbox {
display: grid;
height: 100%;
}
.center-fit {
max-width: 100%;
max-height: 100vh;
margin: auto;
}
</style>
</head>
<body>
<div class="imgbox">
<img class="center-fit" src='pic.png'>
</div>
</body>
</html>

The [other, old] solution, using JQuery, sets the height of the image container (body in the example below) so that the max-height property on the image works as expected. The image will also automatically resize when the client window is resized.

<!DOCTYPE html>
<html>
<head>
<style>
* {
padding: 0;
margin: 0;
}
.fit { /* set relative picture size */
max-width: 100%;
max-height: 100%;
}
.center {
display: block;
margin: auto;
}
</style>
</head>
<body>

<img class="center fit" src="pic.jpg" >

<script src="http://code.jquery.com/jquery-latest.js"></script>
<script type="text/javascript" language="JavaScript">
function set_body_height() { // set body height = window height
$('body').height($(window).height());
}
$(document).ready(function() {
$(window).bind('resize', set_body_height);
set_body_height();
});
</script>

</body>
</html>

Note: User gutierrezalex packaged a very similar solution as a JQuery plugin on this page.

Automatically resize images with browser size using CSS

To make the images flexible, simply add max-width:100% and
height:auto. Image max-width:100% and height:auto works in IE7,
but not in IE8 (yes, another weird IE bug). To fix this, you need to
add width:auto\9 for IE8.

source:
http://webdesignerwall.com/tutorials/responsive-design-with-css3-media-queries

for example :

img {
max-width: 100%;
height: auto;
width: auto\9; /* ie8 */
}

and then any images you add simply using the img tag will be flexible

JSFiddle example here. No JavaScript required. Works in latest versions of Chrome, Firefox and IE (which is all I've tested).

Chrome Squishing img on browser height resize

Try this

.preview img{
max-height:90%;
max-width:100%;
}

using max-height and max-width will make it scale proportionally.



Related Topics



Leave a reply



Submit