How to get responsive images working with JCrop - jcrop

I see some solutions where the truesize property is used to get JCrop to work with responsive images correctly. However, I'm having a hard time getting the images responsive in the first place when using JCrop. If I remove the jCrop code and add the following css, the image is responsive.
In short - JCrop works. Responsive image works. But when put together, the image isn't responsive.
JSFiddle here: Just uncomment the css.
http://jsfiddle.net/work77/oh5esg19/
img{
max-width:80%;
max-height:80%;
}
Very similar question is unanswered here:
Jquery JCrop functionality on fluid images
Any suggestions?
Thanks.

Try with:
img {
max-width:80%;
height:auto;
}
.jcrop-holder img {
max-width: none;
}

instead of setting the max width with css you can limit it with jcrop.
$('#cropbox').Jcrop({
aspectRatio: 1,
boxWidth: 450, //Maximum width you want for your bigger images
boxHeight: 400, //Maximum Height for your bigger images
onSelect: updateCoords,
});
Setting boxWidth and boxHeight will set the size of your box and the image inside will keep its propotions.

Related

How to Center and make full width youtube iframe in responsive view?

I have some iframe youtube video on my website. In esponsive view, they are not centered and not full width.
You can see it there:
http://spitzpomeranian.com/fr
Here is the screenshot of my problem
http://prntscr.com/bxn4pe
I tried to edit the css code in jconsole but I couldn't find the solution.
Is there any expert who can tell me how to center and make full width the videos?
You can override width of the iframe in css
iframe{ /*use class or id for the iframe*/
width:100%!important;
height:auto!important;
}
In your case there are some other div that needs to be given 100% width
.resp_video{
width:100%;
}
.wrap_video{
width:100%; /*adjust the margin to make the div fit inside the page without horizontal scrollbar*/
}
You the use above code within your responsive #media query
See Fluid Width YouTube Videos
This solution uses jquery
I think once you have the video going down you can use media query to center them both by making the width 100%.

Give dummy image natural width and height to act responsively

I'm using jQuery Lazyload Plugin. Before the images are loaded I use a dummy image as placeholder which is a 20x20 pixels blank PNG. Also I'm using jQuery wookMark which is a dynamic grid plugin. For this plugin to work I need the images to be in their correct aspect ratio so the plugin can calculate the suitable position of each grid element in the page.
I have width and height attributes on img tag set to the correct dimensions, but that doesn't have any effect on the dummy image and it will be shown as a square, no matter what.
I can use inline styles to set width and height for each image, but this approach will stop the image from being responsive in other dimensions.
Is there a way to give an image width and height in a way that it act like it is its real dimensions?
Here's the pen to look at:
http://codepen.io/anon/pen/iaIoJ
The only way you're going to get what you want is by using some javascript. You're already using jQuery so that will make it a bit easier.
Use the following CSS to begin with (as an example):
.myImage {
width: 300px;
height: 400px;
}
then when the images are loaded (in some sort of callback function I presume):
$('.myImage').css('width','100%');
$('.myImage').css('height','auto');
Alternatively, you can work with a placeHolder css class that has this height and widht, and then $('myImage').removeClass('placeHolder'); to clear it from the images.
I found a good way for it.It's not going to be pure css, but that's fine by me :)
My solution is to set the image height to 0 and use padding-bottom to maintain the aspect ratio:
<img src="./blank.png" style="height:0;padding-bottom:133.333%">
And also having a class for the img tag when the actual image is loaded:
img.loaded {
height:auto !important;
padding-bottom:0 !important;
}
Here's the pen for this example: http://codepen.io/nOji/pen/yoshA
Hope you find it useful.

keep proportions of image when scrolling out (ctrl - ) css

I am having this issue at: http://bananabay.dejaloasi.com/ where when i zoom out the image of the slider get cuted and won't allow to see correctly. I've already read and try this Zoom in/out how do I keep the aspect ratio?, applying the height auto on the img and both of max width and height. But still haven't got the expected results. Any help would be very helpful.
Try adding this css:
.tp-simpleresponsive .slotholder *, .tp-simpleresponsive img {
width: auto !important;
}
This will get the image maintain proportion but on large screen image wont expand to cover entire screen & it shouldn't cuz it gets pixelated if stretched

Max-height (and aspect ratio) issue in Chrome, when I want to make an image gallery with floating height

A few weeks ago I working on this site. This is my next portfolio site. I want to make this structure, when I finish:
Header
Horizontal image gallery with floating height
Footer
I want to create something similar, just like the 22slides.com portfolio sites for photographers. If you change your browser's window size or press full screen button, the img element or the image's div automatically change his height.
I putted in the CSS a "max-height" parameter, to prevent the images never become bigger than their original resolution. It's a serious issue on huge resolution screens. but in Chrome it's not working properly, because the aspect ratios become wrong. If you press full screen, the aspect ratio more bad. In every other latest browser (Firefox, Safari, Opera, IE8-9) working normally. I created a custome CSS only for chrome with this command (but now I uncommented this in HTML to show you the Chrome aspect ratio problem):
#portfolio img { max-height: none; }
So with this line, the images using the biggest possible height in Chrome and the aspect ratios are correct. But it's a problem for me. I not want that a 1024x683px image showed bigger than his actual resolution on a FullHD monitor.
I think the best solution, if there's a javascript, which is dynamically escribe a width and height for every single image and keep the original aspect ratio. 22slides.com using something similar javascript, but I'm not a javascript programmer at all. :(
The images HTML structure:
<div id="portfolio">
<img src="image1.jpg" alt="" />
<img src="image2.jpg" alt="" />
</div>
CSS (max-height is very little number, just to show you the problem in Chrome):
#portfolio { white-space: nowrap; float: left; }
#portfolio img { height: 100%; width: auto !important; min-height: 150px; max-height: 350px; }
I'm using this Jquery Javascript to dynamically change the image's height and bring back the image's overflow on the screen with 130px negative height. Probably not this script causing the problem, becuase if I turn it off, the aspect ratios are more bad in Chrome:
// Dynamical vertical resizing on images and Correct the height (to not overflow the screen)
$(document).ready(function(){
$(window).load(function(){ // On load
$('#portfolio img').css({'height':(($(window).height())-130)+'px'}); // Adjust the number if you change something in CSS
});
$(window).resize(function(){ // On resize
$('#portfolio img').css({'height':(($(window).height())-130)+'px'}); // Adjust the number if you change something in CSS
});
});
I need help! Thank You!
Update:
This javascript written by "Emphram Stavanger" and "nick_w" seems to solve my image fit to browser height problem:
Imagefit vertically
I tried and it's perfectly working with one single image. The image fitting in the available viewport window perfectly, with correct aspect ratio! There is a visual explanation for our problem made by "Emphram Stavanger":
http://www.swfme.com/view/1064342
JsFiddle demo (Basicly it's Emphram Stavanger's code, I just putted in the changes by nick_W, changed Jquery to latest and I putted after the show link:
http://jsfiddle.net/YVqAW/show/
I not tried yet with horizontal scrolling image website, but it's already a big step!
UPDATE 2:
SOLUTION: https://stackoverflow.com/questions/20303672/horizontal-image-slideshow-javascript-not-working-properly-with-portrait-oriente
(And I need help again...) :)
A little late but you can use a div with background-image and set background-size: contain instead of an img tag:
div.image{
background-image: url("your/url/here");
background-size:contain;
background-repeat:no-repeat;
background-position:center;
}
Now you can just set your div size to whatever you want and not only will the image keep its aspect ratio it will also be centralized both vertically and horizontally.
The background-size property is ie>=9 only though.

CSS - Making a repeating background image stretch to browser window size

This is a problem with a theme that I bought, and I have already tried to contact the owner (with no luck).
It should be a fairly easy fix, it's just that I can't work out how to do it! (I have done my research).
You can view the theme here: http://igeekify.com/_templates/liftoff/www/
To re-create the problem, just drag the window size so that it is smaller in width than the content, then scroll to the right. You will notice the header background doesn't stretch all the way.
The background image is for the DIV '#frame-header', which has the class '.wrapper'. I believe that the problem has something to do with the width of '.wrapper' which is defined.
Any help is really appreciated!
I think you might need to add a min-width property to the 'frame-header' div:
<style type="text/css">
#frame-header
{
min-width: 940px;
}
</style>
Try using the following code:
image width:100%;

Resources