i have code:
<div class="container">
<li class="block2"></li>
<ul class="posts first">
<li class="block"></li>
<li class="block"></li>
<li class="block"></li>
<li class="block"></li>
<li class="block"></li>
<li class="block"></li>
<li class="block"></li>
<li class="block"></li>
<li class="block"></li>
</ul>
<ul class="posts second">
<li class="block"></li>
<li class="block"></li>
<li class="block"></li>
<li class="block"></li>
<li class="block"></li>
<li class="block"></li>
<li class="block"></li>
<li class="block"></li>
</ul>
</div>
and css:
container{
width:940px;
margin: 0 auto;
padding:40px;
background:grey;
}
.container:after {
content: "";
display: table;
clear: both;
}
.block{
float:left;
border:1px solid #ccc;
width:216px;
height:186px;
margin: 0 0 20px 22px;
list-style: none;
}
.block2{
float:right;
border:1px solid #fff;
clear:both;
width:217px;
height:603px;
list-style:none;
}
.posts{
margin: 0;
padding: 0;
}
.first .block:nth-child(3n+1){
margin-left:0px;
clear:left;
}
.second .block:nth-child(4n+1){
margin-left:0px;
clear:left;
}
It is ok when browser zoom is 100%, but when i zoom browser window to 25%, floats going move. What i doing wrong and how can i fix it? Code on fiddle: https://jsfiddle.net/92j5yr6c/1/
i need something like this on 25% zoom link
The easiest way to tackle this with the given code is IMHO:
1) Adjust the error in your CSS (I'm assuming that was only a copy error for your JsFiddle) - your container-class is missing the period to make it actually a class. Change
container{ to .container{
and 2)
Change from border to outline (I assume this is acceptable), since borders tend to remain above "just a fraction of a pixel" wide, they end up adding up to more width than is available. And an outline doesn't grow the object, it just sits on top.
works for me:
https://jsfiddle.net/c0hfopug/
Related
I have a list of an unknown number of items. The container has a border top that shows the width.
No matter the browser size (responsive) the list items should occupy all the width of the container. Currently, as you can see, there is a space to the right of the container. The last li item of a row should be in line with the end of the border.
How can it be done without a lot of media queries?
End result as the image bellow. Basically the thing that should change on resize is the space between list items..
Thanks!
.Container{
width:40px;
height:40px;
background-color:red;
display:inline-block;
}
#list{
padding:20px 0 0 0;
border-top: 4px solid black;
width:50%;
list-style-type:none;
}
<ul id="list">
<li class="Container"></li>
<li class="Container"></li>
<li class="Container"></li>
<li class="Container"></li>
<li class="Container"></li>
<li class="Container"></li>
<li class="Container"></li>
<li class="Container"></li>
<li class="Container"></li>
<li class="Container"></li>
<li class="Container"></li>
<li class="Container"></li>
<li class="Container"></li>
<li class="Container"></li>
<li class="Container"></li>
<li class="Container"></li>
<li class="Container"></li>
<li class="Container"></li>
<li class="Container"></li>
</ul
Here's a flex solution:
#list{
display: flex;
flex-flow: wrap;
justify-content: space-between;
padding:20px 0 0 0;
border-top: 4px solid black;
width:30%;
list-style-type:none;
}
.Container{
width:40px;
height:40px;
background-color:red;
margin: 1px;
}
This works for all rows except the last one:
A fix is to add additional elements, with visibility hidden:
.hidden {
visibility: hidden;
}
<li class="Container hidden"></li>
<li class="Container hidden"></li>
...
Since elements with visibility: hidden still take up screen space, the flex box will take them into account during layout:
In this fiddle, the elements stay evenly spaced as you grow and shrink the viewport.
I have a very simple vertical bar chart made solely by css:
it is made of list items:
<ul class="graph">
<li style="height:50%; ">25</li>
<li style="height:80%;">40</li>
<li style="height:20%;">10</li>
<li style="height:40%;">20</li>
<li style="height:10%;">5</li>
</ul>
with the help of css:
.graph {
width:100%;
height:250px;
position:relative;
background-color:gray;
}
.graph li{
bottom:0;
width:5%;
text-align:center;
background-color:#9FC;
list-style:none;
position:relative;
border-style:solid;
border-width:1px;
display:inline-block;}
the problem is that the bars are upside-down. How could I make them right way up?
thanks
Your li elements should be positioned absolute. However you need to set margin for each element. I used it by adding left property:
<ul class="graph">
<li style="height:50%; ">25</li>
<li style="height:80%;left:20%">40</li>
<li style="height:20%;left:40%">10</li>
<li style="height:40%;left:60%">20</li>
<li style="height:10%;left:80%">5</li>
</ul>
And in CSS i modified this:
.graph li {
position:absolute;
}
DEMO
The following is a screen capture of the issue that i'm faced with. The drop down menu is supposed to appear under the second menu item in the top menu.
The HTML is,
<nav class="nav">
<ul>
<li class="menu-item">Hi Alexander!</li>
<li class="menu-item"><a>My Account</a>
<div class="my-sub-menu">
<ul class="sub-list">
<li class="list-item"><a>History</a></li>
<li class="list-item"><a>Personal Details</a></li>
<li class="list-item"><a>Preferences</a></li>
<li class="list-item"><a>Bonuses</a></li>
<li class="list-item"><a>Wishlist</a></li>
<li class="list-item"><a>Newsletter</a></li>
<li class="list-item"><a>Invite Friends</a></li>
<li class="list-item"><a>FAQ</a></li>
<li class="list-item"><a>Sign out</a></li>
</ul>
</div>
</li>
<li class="menu-item"><a>Contact Us</a></li>
<li class="menu-item"><a>Chat</a></li>
<li class="menu-item"><a>Chat</a></li>
</ul>
</nav>
The CSS is as follows,
.nav {
margin-top: 2px;
position: relative;
float: right;
}
.nav > ul {
padding: 0;
margin: 0;
}
.menu-item{
list-style: none;
float: left;
}
.menu-item .my-sub-menu {
visibility: hidden;
position: absolute;
padding: 0;
margin: 0;
}
.menu-item:hover .my-sub-menu {
visibility: visible;
}
.list-item {
list-style: none;
}
I need the sub menu to appear under the second item in the top menu. This is only in firefox and IE but chrome renders it perfectly. I cant figure out what the issue is. Is there at least e fix that i could use for these two browsers? or another alternative to get around this issue.
Tahnk you in advance.
If you add position:relative to .menu-item it will make the absolute positioning work from the list item itself. The only draw back is if you are using a percentage based width on your drop down it will take the width of the parent li as 100% so a pixel width may have to be specified.
try doing
.sub-list{
padding:0px !important;
}
and if by second menu u want it to come under contact us
then change the position of the div
<div class="my-sub-menu">
<ul class="sub-list">
<li class="list-item"><a>History</a></li>
<li class="list-item"><a>Personal Details</a></li>
<li class="list-item"><a>Preferences</a></li>
<li class="list-item"><a>Bonuses</a></li>
<li class="list-item"><a>Wishlist</a></li>
<li class="list-item"><a>Newsletter</a></li>
<li class="list-item"><a>Invite Friends</a></li>
<li class="list-item"><a>FAQ</a></li>
<li class="list-item"><a>Sign out</a></li>
</ul>
</div>
into the next li element ie cntact us
kind of a fiddle
fiddle ex
I have two UL's:
How can I add text to appear in the top green area.
The text needs to not be in an LI.
Every attempt I make has the text appear outside the boxes. I've had the two UL's wrapped in both a div and a span (currently a span as below) with text before the UL but but neither helped and the text was still outside.
jsfiddle: http://jsfiddle.net/gThjy/
<html>
<head>
<style>
#list_to_process, #categories {
color: blue; background-color: green; border: solid;
border-width: 4px; padding-top:40px
}
.panel { color: red; background-color: yellow;
border: solid; border-width: 4px }
ul { padding: 10px; margin: 50px; float:left; list-style:none; }
li { color: yellow; padding: 25px 80px; cursor: move; }
li:nth-child(even) { background-color: #000 }
li:nth-child(odd) { background-color: #666 }
</style>
</head>
<body>
<span class="a_list">
header1
<ul id="list_to_process">
<li class="to_process" id="left1">1</li>
<li class="to_process" id="left2">2</li>
<li class="to_process" id="left3">3</li>
<li class="to_process" id="left4">4</li>
<li class="to_process" id="left5">5</li>
</ul>
</span>
<span class="a_list">
<ul id="categories">
<li id="righta">a</li>
<li id="rightb">b</li>
<li id="rightc">c</li>
<li id="rightd">d</li>
<li id="righte">e</li>
</ul>
</span>
</body>
</html>
With your current markup this addition to CSS will work and be semantic:
#list_to_process:before, #categories:before{
content:"Read this: ";
}
Maybe this could help:
<ul id="list_to_process">
Header 1
<li class="to_process" id="left1">1</li>
<li class="to_process" id="left2">2</li>
<li class="to_process" id="left3">3</li>
<li class="to_process" id="left4">4</li>
<li class="to_process" id="left5">5</li>
</ul>
<ul id="categories">
Header 2
<li id="righta">a</li>
<li id="rightb">b</li>
<li id="rightc">c</li>
<li id="rightd">d</li>
<li id="righte">e</li>
</ul>
Well its only valid in HTML to have an <li> as a child of a <ul> or <ol> so wrapping any text in a different element isn't possible. You can simply just add text directly after the starting tag for the <ul> and it'll show up in the green area, though I'm not sure thats exactly what you're after. I'm also unsure of whether its valid to have a text-node directly after a <ul> tag, though I will try to find a source.
http://jsfiddle.net/PerfectDark/gThjy/5/
Update: Adding text before the starting <ul> tag is also invalid according to the validator:
Line 38, Column 10: Text not allowed in element ul in this context.
I think your best option is to absolutely position an element to have it appear its inside the box.
I am stumped. I am trying to make a set of icons that sit inside a container with a fixed width. The elements must be inside the parent container but must extend beyond the boundary and not line break when they reach the right border of the parent.
I am using Floated li elements
Here is the fiddle
Would like it to look like this.
Not this:
Thanks for any Help.
Here is the Code:
<div class="mainFooter">
<div class="iconContainer">
<ul class="nav nav-pills">
<li rel="tooltip" data-original-title="Services"><a class="icon-th-list icon-white">A</a>
</li>
<li class="" rel="tooltip" data-original-title="Assets"><a class="icon-briefcase icon-white">B</a>
</li>
<li class="" rel="tooltip" data-original-title="Clients"><a class="icon-group icon-white">C</a>
</li>
<li class="" rel="tooltip" data-original-title="Reports"><a class="icon-dashboard icon-white">D</a>
</li>
<li class="" rel="tooltip" data-original-title="Preferences"><a class="icon-cogs icon-white">E</a>
</li>
<li class="" rel="tooltip" data-original-title="Assets"><a class="icon-briefcase icon-white">F</a>
</li>
<li class="" rel="tooltip" data-original-title="Assets"><a class="icon-briefcase icon-white">G</a>
</li>
</ul>
</div>
.mainFooter {
background: #dddddd;
position: relative;
height: 40px;
width:30%;
}
.iconContainer {
position: absolute;
width: 100%;
border:1px solid red;
top:5px;
}
.mainFooter .nav > li{
float:left;
}
.mainFooter .nav > li > a {
padding:0px;
margin: 1px;
height:25px;
width:30px;
background:#2f65bb;
color: #ffffff;
font-size: 130%;
line-height: 25px;
display: inline-block;
text-align:center;
}
.white-space: nowrap on the <ul>. Do not float the elements, but use display: inline-block.
http://jsfiddle.net/nJydR/3/
you may try to setup fixed width for .nav-pills, something like
.nav-pills {
width: 230px;
}
http://jsfiddle.net/nJydR/4/