I have a left/right border on a list to create a separation effect.
Ex: Link1 | Link2 | ...
I want the lines on the border to be a bit shorter than the total height of the object -- maybe 50% of the total height and centered vertically. However, they are 100% of height. How can I set a height on a border and center it vertically?
Thanks!
<ul class="nav pull-right" style="line-height:30px;">
<li class="dropdown pull-right" style="line-height:20px;border-left: 1px solid #e3e3e3;border-right: 1px solid #e3e3e3;">
<a href="#" class="dropdown-toggle" data-toggle="dropdown">
{% if notice_unseen_count %} <span class="badge badge-warning" style="line-height:15px;">{{ notice_unseen_count }}</span>{% else %}<span class="badge" style="line-height:15px;">0</span>{% endif %}
</a>
<ul class="dropdown-menu">
<li>Inbox</li>
<li class="divider"></li>
<li>Invitations</li>
<li class="divider"></li>
<li>All Notifications</li>
</ul>
</li>
Don't blow up your list with a divider-element. Try this. You can easily adjust the size/height of the border that is created by using the :after pseudo element:
Demo
Try before buy
HTML
<ul>
<li>Inbox</li>
<li>Invitations</li>
<li>All Notifications</li>
</ul>
CSS
ul {
margin: 0;
padding 0;
list-style: none;
}
ul > li {
float: left;
height: 30px;
line-height: 30px;
background: red;
}
ul > li:after {
content: '';
display:block;
float: right;
height: 15px;
width: 1px;
background: #ccc;
margin: 7px 10px 0 10px;
}
Last "border"
To remove the border from the last element, this CSS rule does the job:
ul > li:last-child:after {
content: none;
}
The border lengths will always be >= element's width/height, so you cannot set it to 50% or anything. See the box model: http://css-tricks.com/the-css-box-model/
If you want to style those separation bars, suggest using a background image.
.divider {
background: transparent url('link/to/separator.gif') right center no-repeat;
padding: auto 10px;
}
This will add separater image to the right of all the links with divider class. For the last item in the list, you don't need to apply the class.
Related
I'm trying to make a basic navigation bar where a child dropdown appears when hovering over a list item. I want to position this dropdown starting at the right most edge of the list item I am hovering over, but I want it this dropdown be able to scale bigger than the list item you're hovering over.
The trouble is that when I position the parent relative, the dropdown's width is constricted to the width of the list item you're hovering over, when I remove postion relative I lose the ability to position it the way I want it.
When the parent List item doesn't have position relative it looks like this:
But I want the right edge of that dropdown to align with the right side of the list item I'm hovering on. When I add position relative to the list items, the width of the dropdown is contsrained like this:
The markup looks like follows:
<nav>
<ul class="outer-list">
<li>
<a>
Work
</a>
<ul class="inner-list">
<li>Sub1</li>
<li>Sub2</li>
<li>Sub3</li>
</ul>
</li>
</ul>
<ul class="outer-list">
<li>
<a>
Contact
</a>
</li>
</ul>
<ul class="outer-list">
<li>
<a>
Helpdesk
</a>
<ul class="inner-list">
<li>Sub1</li>
<li>Sub2</li>
<li>Sub3</li>
</ul>
</li>
</ul>
<ul class="outer-list">
<li>
<a>
Subscriptions
</a>
<ul class="inner-list">
<li>Sub1</li>
<li>Sub2</li>
<li>Sub3</li>
</ul>
</li>
</ul>
I am not in charge of the markup, but if it needs to change to allow for a solution that is fine.
My CSS is as follows:
.outer-list{
.dropdown{
padding-right: 20px;
a{
color: black;
text-decoration: none;
position: relative;
.icon-dropdown{
position: absolute;
display: inline-block;
width: 6px;
height: 4px;
background-image: url('./Assets/BlueArrowIcon.svg');
background-size: cover;
background-position: center;
top: 50%;
right: -11px;
transform: translateY(-50%)
}
}
.inner-list{
padding: 25px 20px;
display: none;
position: absolute;
background-color: $color-white;
box-shadow: 5px 0px 50px rgba(0,0,0,0.16);
z-index: 1;
max-width: 310px;
li{
margin-bottom: 20px;
&:hover{
a{
color: $color-dark-red;
}
}
}
}
&:hover{
a{
color: $color-blue;
}
.inner-list{
display: block;
a{
color: black;
}
}
}
}
&:last-of-type{
.dropdown{
padding-right: 0px;
}
}
}
If anyone could help me that would be much appreciated.
I'm trying to figure out how to position a flowchart built with ul list growing like a tree, from bottom-up.
It's a genealogical family tree. I've made it from top down using this great code here but I want the first element in the bottom, above it the parents and above it the grandparents and so on...
Here is the code:
HTML
<div class="tree">
<ul>
<li>
<div class="dados_membro">Me</div>
<ul>
<li>
<div class="dados_membro">Father</div>
<ul>
<li>
<div class="dados_membro">Grandfather</div>
</li>
<li>
<div class="dados_membro">Grandmother</div>
</li>
</ul>
</li>
<li>
<div class="dados_membro">Mother</div>
<ul>
<li>
<div class="dados_membro">Grandfather</div>
</li>
<li>
<div class="dados_membro">Grandmother</div>
</li>
</ul>
</li>
</ul>
</li>
</ul>
</div>
CSS
.tree ul {
padding-top: 20px;
position: relative;
}
.tree li {
float: left;
text-align: center;
list-style-type: none;
position: relative;
padding: 39px 5px 0 5px;
}
.dados_membro {
border: 1px solid;
border-radius: 20px;
width: 300px;
margin: auto;
text-align:left;
padding:10px
}
I'm testing some rules in this fiddle and could position the first node "Me" in the bottom and the other ones up with the CSS bellow, but all the nodes in the same level (parents, grandparents and so on..) get pilled up.
.tree ul {
position: absolute;
bottom:0;
}
.tree ul li ul{
position:relative;
}
.tree li {
float: right;
text-align: center;
list-style-type: none;
position: relative;
padding: 20px 5px 0 5px;
margin-top:-120px
}
.dados_membro {
border: 1px solid;
border-radius: 5px;
width: 100px;
margin: auto;
text-align:left;
padding:10px
}
I don't know how big will the tree grow up nor if all the nodes will have elements. Can't use javascript for this. Any ideas?
You could change the order of the elements using the flexbox property flex-direction: column-reverse, if that is an option for your project (see compatibility table).
To revert the order of the list I gave the main container position: absolute with bottom:0, the <ul>s a position:relative and all <li>s position:absolute with bottom:50px, except for the first level that I want to be in the bottom of the container.
This way every <li> is positioned 50px above its parent <ul> that has relative position.
One last tweak to achieve the tree style was adding a class for female and male parents in order to position each one in the left and in the right above its child node. Since I'm generating this tree dinamically I can count how many levels does the tree has and calculate the distance between father/mother nodes. If I could not control the html dinamically, I would need to use javascript to count the nodes and apply the css rules on the fly (maybe I will do ti in the future, just to animate the tree generation).
The new code is here
HTML
<div class="tree">
<ul>
<li>
<div class="dados_membro">Me</div>
<ul>
<li class="f1">
<div class="dados_membro">Father</div>
<ul>
<li class="f2">
<div class="dados_membro">Grandfather f</div>
</li>
<li class="m2">
<div class="dados_membro">Grandmotherf </div>
</li>
</ul>
</li>
<li class="m1">
<div class="dados_membro">Mother</div>
<ul>
<li class="f2">
<div class="dados_membro">Grandfather m</div>
</li>
<li class="m2">
<div class="dados_membro">Grandmother m</div>
</li>
</ul>
</li>
</ul>
</li>
</ul>
</div>
CSS
.tree {
position:absolute;
bottom: 0;
left:300px
}
.tree ul {
position: relative;
list-style:none;
}
.tree ul li ul li{
position: absolute;
bottom: 50px;
}
.f1{
left:-150px;
}
.m1 {
left:150px;
}
.f2{
left:-80px;
}
.m2 {
left:80px;
}
.dados_membro {
border: 1px solid;
border-radius: 5px;
width: 100px;
margin: auto;
text-align:left;
padding:10px
}
I have some bootstrap tabs, which align to the right inside my container:
https://jsfiddle.net/yc2dxnev/
This is the code:
<div class=container>
<ul id="tabs" class="tabs-right tabs">
<li class="banana active"><a>Banana</a></li>
<li class="monkey"><a>Monkey</a></li>
<li class="woods"><a>Woods</a></li>
</ul>
</div>
<style>
ul.tabs a {
display: block;
outline: none;
}
ul.tabs {
list-style: none;
padding: 0;
margin: 0;
display: block;
}
ul.tabs>li {
display: inline-block;
position: relative;
margin-top: 5px;
margin-bottom: -1px;
}
What I want to do is keep the tabs right and make only the left tab stick to the left, but in the same time fill the area to the next tab. It is hard to explain so I posted an image:
http://s16.postimg.org/bhr4qzt51/002.jpg
I do not know how to achieve it, maybe you know a trick.
Your right tabs should be right, so float them to the right using float:right;. Since you want to have the first list item filling the whole space, you have to put it at the end of your ul and add overflow:hidden; to it. Your code would look like this:
<div class="container">
<ul id="tabs" class="tabs-right tabs" data-tabs="tabs" style="">
<li class="monkey"><a>Monkey</a></li>
<li class="woods"><a>Woods</a></li>
<li class="banana active"><a>Banana</a></li> // move this li item to the end
</ul>
</div>
ul.tabs>li.active {
border-bottom-color: #FFF;
background-color: #FFF;
overflow:hidden;
}
.monkey, .woods{
float:right;
}
Have a look at this fiddle.
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/
I have the following HTML code:
<ul class="blogEntry">
<li class="title section">
<span><asp:Literal ID="litTitle" runat="server" /></span>
<span class="date"><asp:Literal ID="litDate" runat="server" Text="10/1/1000" /></span>
</li>
<li class="body section"><asp:Literal ID="litBody" runat="server" /></li>
<li class="tags section">
<ul class="tags">
<li class="tag">Tag 1</li>
<li class="tag">Tag 2</li>
<li class="tag">Tag 3</li>
</ul>
</li>
</ul>
And the following CSS code:
ul.blogEntry
{
border: 1px solid black;
border-bottom: 0px;
padding: 0px;
}
ul.blogEntry li.section, ul.blogEntry li.lastsection
{
list-style: none;
}
ul.blogEntry li.title
{
background-color: #67A7FF;
font-size: 14px;
font-weight: bold;
}
ul.blogEntry li.title span
{
display: inline;
}
ul.blogEntry li.title.section span.date
{
float: right;
}
ul.blogEntry li.section
{
padding: 4px;
border-bottom: 1px solid black;
}
As is, the date will drop to a new line and float to the right. If I change the ul.blogEntry li.title span CSS and add float: left; The outer LI element's height shrinks and the bottom border cuts right through the spans' text. Advice?
Please don't add any elements for clearing. Elements which only enable specific styling significantly breaks semantics and separation of concerns.
The simple answer is to add overflow:auto; to the container element (i.e. li.title) but there are other ways:
http://www.positioniseverything.net/easyclearing.html
http://www.innovatingtomorrow.net/2008/03/24/how-clear-floats-css
http://www.sitepoint.com/blogs/2005/02/26/simple-clearing-of-floats/
Clearing blocks are EVIL.
try:
.section {min-height: 10px;}
that should clear your floats for all your section classes in ie7 and 8. you may try floating the element above your date left to see if that works.
also, when floating something, you should usually set the width