HTML/CSS - How do I make divs to size according to their contents?
Tags: css,html,autosize
Problem :
I have 2 divs side by side.
In the first div, I have 2 labels side by side, and one input text below them. One of the labels is an error information. Sometimes it will be displayed, sometimes not. When it's not display, I'd like the div to resize to be smaller, so the second div can be closer to it.
The second thing is the same thing, except it has one label div, therefore it doesn't requires a resize.
Is there a way to achieve what I want? There is an awesomely drawn example of what I want to acahieve below:
This is the code.
<div id="main-div">
<div id="address-number-div">
<label>Number</label>
<label class="error" id="number-error">Empty Field</label>
<input id="number-input" onfocus="onfocus('number-error')"/>
</div>
<div id="address-complement-div">
<label>Complement</label>
<input id="complement-input" />
</div>
and CSS:
div {border: 1px solid #000000; padding: 5px;}
.error{color:#FF0000; margin-left:5px;}
#main-div div {display:inline-block;}
#main-div input {display:block;}
#number-input {
width: 16%;
}
Solution :
Have a look at this DEMO.
Floating your divs left should solve this problem.
CSS Howto..
Maybe take a look at https://github.com/mrclay/minify, while it includes a wrapper for the YUI compressor (which itself is a java command line tool) it's also a standalone PHP library. http://code.google.com/p/minify/wiki/UserGuide...
Simplest way to achieve this is by adding a function function myFunction(){ document.getElementById("myRate1").value = $('#rate1').swidget().value(); } Then adding a Hidden text box in form like this <input type="hidden" name="myRate1" id="myRate1"/>...
You need to set the display:flex; properties on ul and li , not nav and li . here ul is your only one box that is 'flexing' . http://jsfiddle.net/qwPER/1/...
From what I can gather, it looks like you should be using the fieldset element (as you are "grouping" form elements together), which conveniently also looks the way you want...
var cb = function(href) { var l = document.createElement('link'); l.rel = 'stylesheet'; l.href = href; var h = document.getElementsByTagName('head')[0]; h.appendChild(l); }; Call cb() as many times as you need with...
Use the first child selector: > .menu > li { font-weight: bold; } Not that if you need to support IE6, you'll have to do it manually, as IE6 doesn't...
I've stumbled upon a potential fix for this problem. If I set all blockquotes with the CSS property overflow: auto, it makes them reduce to the desired width when they'd...
Friend, it is 10px not 10 for the padding value. <li style="padding: 10;">123</li> should be <li style="padding: 10px;">123</li> Cheers,...
You can put overflow:hidden on the third column and it will automatically take up the remaining space. See this fiddle. Example: HTML: <div class="container"> <div class="one"></div> <div class="two"></div> <div class="three"></div>...
Here is your working and clean code. The navigation is in center and you can preview in full-screen. Explanation Position: absolute should be in your dropdown navigation Need not to...
You can do it with HTML <div id="yourImage" ></div> CSS #yourImage { background-image: url('image1.jpg'); } #yourImage:hover { background-image: url('overimage.jpg'), url('image1.jpg'); } ...
The CSS would load fine (assuming the URL to file.html is /templates/file.html and you aren't just using it as a server side template for a different URL) if you got...
Use the attribute-starts-with selector: a[href^="javascript:"], a[href^="#"] { color: red; } ...
You can set the image absolute and position it horizontally by adding left:50% and translatex(-50%) demo - http://jsfiddle.net/puqd2bn5/9/...
You have to set the height:100% on html and body tags, and if the hero div has a parent, it'll need that as well. Example http://jsfiddle.net/xExSE/...
It's mean: fa-arrow-circle-o-down. It's used with Font Awsome plugin for displaing "font-icons". For use it you must read the documentation. CSS has a property called content. It can only be...
My question is how I should go about formatting my CSS to change these settings. Should I just create classes with those names? Yes. These are the classes the...
Giving class label margin seems to help: span.label { float: right; margin: 10px; } ...
Here's your thing working - http://jsfiddle.net/eAfTc/ .myClass { fill: url(#image); stroke: red; stroke-width: 5; } <svg id='pattern' xmlns="http://www.w3.org/2000/svg" version="1.1"> <defs> <pattern id='image' width="1" height="1" viewBox="0 0 100 100" preserveAspectRatio="none"> <image...
Like this? http://codepen.io/anon/pen/sypjf You can use 'forwards' so that the CSS animation does not repeat: .animateUp { -webkit-animation: animateUp .6s ease-in-out forwards; animation: animateUp .6s ease-in-out forwards; } .animateDown {...
I think here is you want: <div class="row"> <div class="col-xs-4 col-md-2"> A </div> <div class="col-xs-4 col-md-2 col-md-push-3"> B </div> <div class="col-xs-4 col-md-2 col-md-push-6"> C </div> <div class="col-xs-6 col-md-3 col-md-pull-4"> D...
Your idea seems fine to me (i see no CSS alternative else than using an image ), you could even use different color starting from a length that could be...