How to make image fit in div using Jquery
Tags: jquery,css,xhtml
Problem :
currently, I having a page with the layout like this:
-----------------------------
Header (100%)
-----------------------------
| | Desc |
| unknown size | |
| | 200px |
| Image here | |
| | |
| | |
| | |
| | |
-----------------------------
Footer 100% height stick bottom
-----------------------------
that the idea of the layout. when i resize the height or width, the only thing that resize is the image and it's div
But how should i archive this using either jquery or css?
How should I have the image inside that div resize arcording to the height and width of it's div box?
http://www.msnbc.msn.com/id/35385037/ns/news-picture_stories/displaymode/1247/?beginSlide=1 something like this for example
Solution :
var divElem = $("#yourdivid");
var ht = divElem.height();
var wdt = divElem.width();
$("#yourimageid").css({'height' : ht, 'width' : wdt});
CSS Howto..
Use display: table-cell; + vertical-align: middle; Fiddle .circle { border-radius:50%; border:5px solid black; width:100px; height:100px; box-shadow: 0 0 5px 2px rgba(0, 0, 0, .35); font-family:Century Gothic; color:black; text-align:center; display: table-cell;...
Well this is simple. You just need to have a dropdown element present side by side next to the tab elements, and depending on the viewport size you can toggle...
Your question was not very clear and very vague but it seems that you are adding an unnecessary file by including the bootstrap file twice. If the bootstrap.css you are...
Check out the documentation for .css: http://api.jquery.com/css/ var bodyColor = $(this).css("backgroundColor"); ...
The effects take precedence in the order you place them, so if you put them like this, it should work input[type=text], textarea { -webkit-transition: all 0.30s ease-in-out; -moz-transition: all 0.30s...
You could use nth-child(-n+2) to change the display of the first two elements to inline-block. Example here li.email:nth-child(-n+2) { display:inline-block; } ..and if you want the bullet points, alternative example...
Normally using the window for the scroll event should be sufficient, as it's big enough and the one element, that's being scrolled. If jQuery is loaded correctly, you could try...
Here's how I'd do it: HTML <div id="header"> <ul> <li class="paraLogo">Danny Wong Art</li> <li>Architectural Visualisation</li> <li>Envirnoment</li> <li><a href="design.html">Design</a> </li> <li><a...
I have used setTimeout function to achieve your task... var timer, thisid; $('td').mouseenter(function(){ thisid = $(this); timer = setTimeout(function(){ $(thisid).parent('tr').addClass('blueBgColor'); },2000); }).mouseleave(function(){ clearTimeout(timer); }); and for your reference check this...
Try this: #container { position: relative; } #container canvas, #overlay { position: absolute; } canvas { border: 1px solid black; } <div id="container"> <canvas></canvas> <div id="overlay">This div is over the...
You can't do it, each font needs it's own separate file. You can use a service to convert a ttf to eot, and svg files and then use some code...
Just remove the position:absolute; property for #inner Fiddle: http://jsfiddle.net/Q8NVH/7/...
The short answer is that the browser decides on when to use hardware acceleration to render something; it's not something you can force on any particular class or style. You...
Best way with jQuery $(document).ready(function(){ var str=location.href.toLowerCase(); $(".navigation li a").each(function() { if (str.indexOf(this.href.toLowerCase()) > -1) { $("li.active").removeClass("active"); $(this).parent().addClass("active"); } }); }) ...
Use: option[selected] It means "every option element that has a selected attribute". That should work for you (see example below). Alternatively, if there were more than one option with the...
For a single file you could do : :g/{/normal! f{viB:sort^M What this does : :g/{/ : for every line containing a { normal! : enter normal mode (the ! simply...
You can apply ng-class to determine the active item as below. Set activetab on your ng-click. <li ng-class="{active: activeTab == 'personal'}"><a href="#" ng-click="setActiveTab('personal')" class="">Personal</a></li> <li ng-class="{active: activeTab == 'professional'}"><a href="#"...
footer must be inside body tag.
I suppose that there's some condition on the item that allows you to determine if it is the currently active one. And then you could use the conditional operator...
Your markup is was invalid <style="text/css"> should be <style type="text/css"> Otherwise CSS rules should be applied fine to HTML loaded via AJAX. Update - Tips for debugging unmatched CSS: Use...
With the help from a friend i solved this. It would seem that i had missed some code in the demo. the following script was in it: if (options.thumbnails) {...
You can use the sclass attribute so your css is applied with the default css. <style> .bold{ font-weight: bold; } </style> <grid> <columns> <column/> <column/> </columns> <rows> <row> <label value="${labels.personal.name}"...
<input type="text" value="3" class="field left" readonly> No styling necessary....
I would use <button type="submit"></button> @font-face { font-family: FontAwasome; src: url("https://cdnjs.cloudflare.com/ajax/libs/font-awesome/4.3.0/fonts/fontawesome-webfont.woff"); } .sign-in:after { content: ''; display: inline-block; font-family: FontAwasome; font-size: 2em; line-height: 2.75rem;...
You are using float: left; for your h3 element which is a block level element in nature, so when you float left, the rest of the space gets empty, and...
Answering my own question to help anyone else out with the same problem. The answer was very hard to find but very easy to correct. In my CSS I'd applied...
Working sample: <!DOCTYPE html> <html> <head> <script src="http://code.jquery.com/jquery-1.10.1.min.js"></script> </head> <body> <nav> <ul id="menu"> <li><a href="Home" title="Home">HOME</a></li> <li><a href="Project"...
If you look on google fonts I'm sure you will find something similar. Here is an example of using Google web fonts with a font called "Cookie" and it is...
You can try this: .col-md-4 { position: relative; } .col-md-4 span { position: absolute; top: 0; } .col-md-4 span:last-child { top: auto; bottom: 0; } Working demo...
Unfortunately you cannot do this in pure CSS, by default the child element never inherits the width, you need to specify it, yes, by default it will span 100% if...