I'm trying to take div and resize it according container which is resized on window.resize but i need it to mach some specific aspect ratio.
var hconainer,wcontainer;
hconainer=$('#container').height();
wconainer=$('#container').width();
now i need that h:w=some specific aspect ratio.
Related
I am using TinyMCE editor. However, I have run into a problem. I can add the image and resize it as well but when I resize, both height and width get resized by same proportion.
I want to resize only height without affecting the width and vice-versa. The only way I can do this is by hardcoding width and height values which is pretty tedious job. How to fix it?
When I resize both height and width gets resized, no option to resize them separately
Unlock the width and height by clicking on the the lock button
I have a twitter bootstrap carousel in which I have images and iframes. Images work perfectly because they have img-responsive class and they resize. The iframes don't work like that. I have to give them a width and a height and change their width and height whenever the user resizes the browser.
The carousel can contains only images, only iframes, or images and iframes in the same time.
How can I make the iframes work like the images? Have the same dimensions, resizes in the same way?
My images are 750 x 427px. The thing that passes my mind is to give the iframes width 100% of the container because this work and after this I have to find the height considering that if the width is for example 300px the height should direct proportional with the image dimensions which are 750 x 427px.
We can simply use the rule of three ? Or there is somehthing more complex using image ratio?
Through .height() and .width methods.
You could use $("#imgID").height() to get its height and $("#imgID").width() to get its width. Of course the imgID is replaced with the actual ID of your image.
So I've run into troubles when making my web app responsive. I've managed to make it so that the SVG adapts when the width is resized, but I've run into trouble with height.
The best solution I've come up with for height resize is the following js/jQuery code:
function updateWindow(){
var y = (($(window).height()));
svgMap.style.height=y;
}
updateWindow();
window.onresize = updateWindow;
What this does is set the SVG viewport height to equal that of the window.. This works in a sense that it centers the SVG with the browser window's height. Not so excellent, it screws up on mobile devices and adds a strange top-margin almost. It also makes the SVG slightly smaller unless I multiply "y" by some value greater than one. Doing so, however, increases the margin-top esque gap. How troublesome..
You can view the demo here:
http://zadias.me/SVG/Harrison%20Wilson/HarrisonWils.html
and the demo w/o the height center change here: http://zadias.me/SVG/Harrison%20Wilson/HarrisonWils%20-%20Copy.html
To sum things up, How does one go about centering an SVG within an <object> tag, horizontally AND vertically. Also, I would like it so that the SVG map itself fills the wrapper container.
Any help is appreciated, thanks.
EDIT: So I've given up on trying to get it to just fit the parent's height.. Instead I just wrote some JS that will prompt the user with a warning if the height is too small that it will cause overflow of the page. I also made it so that it would be styled perfectly by adding inline CSS to each page, accompanied with media queries.
If you set the SVG's width and height to 100%, ie.:
<svg width="100%" height=="100%">...
then it should just be a matter of resizing the container that the SVG is inside. The preserveAspectRatio setting of "xMidYMid meet" should then centre it vertically.
In html5 canvas element use I have a problem with default aspect ratio.
The default aspect ratio for the canvas element in Firefox and Safari, at least
appears to be 2/1 for width and height. This is the only combination of height
and width that will produce a 1:1 aspect ration for rectangle drawn to the
canvas element.
So, how do I set the aspect ratio for the canvas element that will allow
a 1:1 ratio for items drawn to it?
I have an account with Coding Forums and have not gotten an adequate response.
I have obtained some print texts on the subject but they do not address this.
I have been programming javascript/html/css for at least 10 years.
I hope I'm not stuck with a unalterable default ratio.
Looking over the list of similar questions, I don't see this particular issue addressed.
The Canvas can have it's own width and height which is independent of the Dom element.
This is causing the non 1:1 aspect ratio.
To fix you need to set the width and height attributes to match the width and height of the dom containing element.
For example, in jquery you can do the following.
$('canvas').attr('width', '100').attr('height', '100');
This will make your canvas a 100 pixel square. Assuming this is in a dom element with matching width and height properties then you'll get 1:1 aspect ratio.
I'm trying to create an image object or canvas object that will resize based on the window dimensions, but keep the aspect ratio. Is this possible?
I know that with canvas, you can maintain bicubic scaling, but is it possible to have the image scale on the window resize while maintaining the aspect ratio?
You might want to give this a shot:
http://css-tricks.com/how-to-resizeable-background-image/