Avoid linebreaks inside a div with dynamic width in IE - html

I'm trying to create a div that would have a dynamic width depending on the content inside that div. It works well in Firefox but in IE I get linebreaks, see screenshot below:
The markup looks like this:
<div class="filter-dropdown">
<div class="filter-dropdown-options-wrapper">
<ul>
<li>
<label>
<input type="checkbox" checked="checked">(Select All)
</label>
</li>
<li>
<label>
<input type="checkbox" value="2010-01-31" checked="checked">2010-01-31
</label>
</li>
</ul>
</div>
<div class="filter-btn-wrapper">
<input type="button" value="Ok" class="btn-filter-ok">
<input type="button" value="Cancel" class="btn-filter-cancel">
</div>
</div>
and CSS looks like this:
.filter-wrapper div.filter-dropdown{
position:absolute;
top:-190px;
right:10px;
border:1px solid #CFD6DA;
z-index:10000;
display:none;
padding:10px;
height:170px;
background-color:#EEF1F2;
}
.filter-wrapper div.filter-dropdown .filter-dropdown-options-wrapper{
border:1px solid #CFD6DA;
padding:5px 10px;
height:130px;
overflow-y:auto;
background-color:#FFFFFF;
width:100%;
}
.filter-wrapper div.filter-dropdown .filter-dropdown-options-wrapper ul{
list-style:none;
padding-left:0px;
margin:0px;
}
.filter-wrapper div.filter-dropdown .filter-dropdown-options-wrapper ul li label{
display:block;
}
.filter-wrapper div.filter-dropdown .filter-btn-wrapper{
margin-top:10px;
text-align:right;
width:130px;
}
.filter-wrapper div.filter-dropdown .filter-btn-wrapper .btn-filter-ok{
margin-right:5px;
width:60px;
}
So, my question is - what do I have to do in order to avoid linebreaks and keep width of the outer div dynamic?

First, make your padding/margins on the right side of your inputs and that box small enough that it doesn't WANT to wrap. It's wrapping because it's running out of room. If you set the background color of the labels you'll probably see where it's ending.
Lastly as a failsafe you can set white-space: nowrap; but this should be a failsafe for funky font size issues and such not your primary solution because it will introduce complications of horizontal scroll bars etc.
Edit: Also, you need to get your <input...> tags out of the <label...> tags. The labels should be attached to the inputs by name, not by virtue of being inside them!

Related

Adjust position of a lightbox without JS

i have a lightbox image inside a div of a scrollable page.
I use everything in % so that every image adjusts to the screen size whether it is mobile or destkop.
The thing is that when I visit my site in mobile and I click in the lightbox, it appears at the bottom of the page! How can I set the position of the lightbox to appear in front of the clickable image?
My HTML is:
<input type="checkbox" id="check" style="display:none;">
<label for="check">
<div id="biteme"><img src="biteme.png"></div>
</label>
<label for="check">
<div id="cover">
<div id="box">
<img src="promociones.png" width="80%">
</div>
</div>
</label>
And my css is:
#biteme {
padding-top:0;
padding-bottom:0;
}
#check:checked ~ label #cover{
display:block;
background:none;
}
#cover{
position:absolute;
top:0;
bottom:0;
left:0;
right:0;
background:none;
display:none;
}
#box{
position: inherit;
top:313%;
bottom:0;
left:16%;
right:0;
margin:auto;
width:80%;
height:auto;
border:none;
opacity:0.9;
background-color:transparent;
background:none;
}
If you can switch them places that will work. You can use z-index to reorder boxes too.

Justify list-item makes big gaps beneath them. Not working as it should

The problem is that the ul.horizontal doesn't work as it should. There is a big gap beneath it and the text-inputs can't retain their 100% width property.
How can I fix this?
<ul class="form">
<li>
<label>Firstname</label> <span>
<input name="title" type="text" placeholder="What is your">
</li>
<li>
<ul class="horizontal">
<li>
<label>Beskrvning</label>
<input name="title" type="text" placeholder="Why does CSS work with fake tags?">
</li>
<li>
<label>Beskrvning</label>
<input name="title" type="text" placeholder="Why does CSS work with fake tags?">
</li>
<li>
<label>Firstname</label>
<input name="title" type="text" placeholder="Why does CSS work with fake tags?">
</li>
</ul>
</li>
css
ul.form {
list-style:none;
padding:0;
margin:20px;
border:1px solid #ccc;
border-radius:5px;
}
li {
border-bottom:1px solid #ccc;
}
li:last-child {
border:0;
}
label {
font-size:12px;
color:#ccc;
padding:5px 10px;
position:absolute;
}
input {
width:100%;
padding:25px 10px 10px 10px;
border:none;
float:left;
background:none;
}
li:before, li:after {
content:"";
display:table;
}
li:after {
clear:both;
}
ul.horizontal {
border:none;
border-radius:0;
margin:0;
text-align: justify
}
ul.horizontal::after {
width: 100%;
display: inline-block;
content:".";
visibility: hidden
}
ul.horizontal li {
display: inline-block;
border:none;
padding-left:40px;
border-left:1px solid #ccc;
}
ul.horizontal li:first-child {
border-left:none;
padding-left:0;
}
The large gap is coming from your ul.horizontal::after (which incidentally I think should only have one colon, yes?), because you have a period in there with display block and a hidden visibility. Comment out the visibility and you can see the period. Simply changing the visibility to hidden does not free up the space it was in on the DOM. You could consider making it a height of 1px if you absolutely have to have it?
I took that out, and saw how your fields broke in terms of 50/50 layout like you want. It will be a little tricky getting a 2-column and a 3-column tabular layout with CSS with inner elements (the inputs) at 100% without using tables. Since that wasn't really the question I just added a quick class for a three-col horizontal UL so we could get rid of that massive space under your horizontal ULs.
http://jsfiddle.net/TLMWa/
Hope this helps!

Facebook-like friend selection checkbox

I'm trying to code a selection like the Facebook "invite friends" selection. I like it because it uses the default checkboxes and not a background simulating the selection of each item.
The problem is that I cannot figure out how can they make the text (friend's name) break into two lines if needed (text is too big)!
I have a simplified example of what I'm trying to achieve. Here's the HTML:
<div class="modal">
<div class="modal-body">
<ul class="unstyled">
<li class="store_selectable">
<input class="checkbox" type="checkbox">
<a href="#">
<div class="store-text">
<div class="iblock"><img alt="Missing" src="http://placehold.it/30x30"></div>
<div class="text"><div>This is the store</div></div>
</div>
</a>
</li>
</ul>
​
And here's the CSS:
body {
padding: 20px;
}
li.store_selectable {
width:161px;
float:left;
margin:0 0px 6px 0px;
overflow:hidden;
font-size:0.9em;
}
li.store_selectable .checkbox {
float:left;
display:inline-block;
margin:12px 6px 0;
}
li.store_selectable .store-text {
display:block;
height:30px;
}
li.store_selectable img {
float:left;
display:block;
width:30px;
height:30px
}
li.store_selectable a {
display:block;text-decoration:none;
padding:2px;
outline:none;
color:#333;
border:1px solid #fff;
border-width:1px 0;
}
li.store_selectable a:hover {
background:cyan;
border:1px solid blue;
border-width:1px 0;
}
li.store_selectable .iblock {
display:inline-block;
vertical-align:middle;
overflow:hidden;
text-align:left;
}
For an easier testing and understanding I've created a jsfiddle here: http://jsfiddle.net/rikas/tpqHd/1/
Now, what I'm trying to do is breaking the text in two lines if the width of the list item is small enough, changing this line: width:161px;. Messing with facebook "invite friends" modal window CSS I can see that they do it, but I can't!
Thanks for your help!
Not quite sure of the interface you are trying to achieve, but the reason for text not wrapping is the css
overflow:hidden;
after removing that consider putting your checkbox and
the text its own div element with class .fl
.fl { display:block; }
to line them side by side
directly under the two create another empty div element with the class of .clear
.clear { display:block; clear:both; line-height:0; }
to prevent the next element inheriting the float:left

CSS tabs positioning

I am trying to use an unordered list to simulate tabs in CSS but the ones I create somehow extend into a form below them (which of course is unintended)
I created the tabs by floating links to the left. This is what I want,
But unfortunately, this is what am getting. Notice how the tabs displace the 'input' elements of the form. What is going on?
Here is my markup and CSS
<link rel='stylesheet' type='text/css' href='style.css'>
<div id='page'>
<ul class='tabs'>
<li><a href='www.google.co.ug'>google search</a></li>
<li><a href='showall.php'>show all names</a></li>
<li><a href='logout.php'>logout</a></li>
</ul>
<form action='storedata.php' method='post'>
<div class='simpledata'>
<label for='fname'>first name</label>
<input class='kyetagisa' type='text' name='fname' size='20'>
</div>
//more elements added here
<input type='submit'>
</form>
</div>
And here is style.css
label
{
text-align:right;
width:150px;
float:left;
clear:both;
margin-right:5px;
}
div.simpledata
{
margin-top:5px;
}
ul
{
list-style:none;
}
ul.tabs a
{
float:left;
margin-right:10px;
color:white;
text-decoration:none;
background-color:#00e;
}
#page
{
background-color:#eee;
margin-left:130px;margin-right:130px;
height:180px;
}
You could use:
form {
clear: both;
}
To force the form (and its child elements) to appear below the ul.
JS Fiddle.
You need to add a clearing div or br after your ul.
I just eliminated the float: left from the label css block.
http://jsfiddle.net/tTrAa/
Setting the 'overflow' style property of the list to 'hidden' should also work.
ul
{
list-style:none;
overflow:hidden;
}

Why this link doesnt get the text-align:right?

I have this code :
<div class="footer_bar_row_desc_richedi">
<a class="myText" href="#">My Text</a>
<div class="myDiv">
&nbsp
</div>
</div>
.myText
{
text-transform:uppercase;
font-weight:bold;
color:#b90e1d;
text-decoration:none;
float:left;
font-size:12px;
padding-top: 1px;
text-align:right;
}
.myDiv
{
float:right;
width:25px;
padding-right:5px;
text-align:right;
margin-bottom:3px;
background:red;
}
and I'd like to put the text on the link to the right, near (on the left) of the red div. Seems that attribute text-align:right; doesnt works. Any Idea?
You need to give your .mytext div a width. It is collapsing to the exact width of your text at the moment which means that right aligning the text looks as if it is doing nothing...
See
http://jsfiddle.net/hS3JA/
by default the A tag has inline display style (fit container to contents size). you must set display:block; so the attributes width, height, text-align will affect the object
try this:
<div class="footer_bar_row_desc_richedi">
<div class="myDiv">
&nbsp
</div>
<a class="myText" href="#">My Text</a>
</div>
.myText
{
text-transform:uppercase;
font-weight:bold;
color:#b90e1d;
text-decoration:none;
float:right;
font-size:12px;
padding-top: 1px;
/*text-align:right;*/
}
.myDiv
{
float:right;
width:25px;
padding-right:5px;
text-align:right;
margin-bottom:3px;
background:red;
}
text-align: right will only align the text to the right inside its own element. Since a is an inline element, it never takes up more width than it needs, and text-align is rendered useless.
Try putting display: inline-block in .myText { } and give it a width.
I had the same problem. I solved it by encapsulating it in paragraph tag...
<p style="text-align:right;">...link...</p>