I have a nested list, and I want to attach some buttons to each entry. But the alignment is very wired. See JSFIDDLE example here.
Basically I want all buttons positioned just like button1. What should I do?
you can add clear right to your li element or if you need more fine tuning for position, try this:
HTML (to correct yours)
<ul>
<li>test <button class='right'>button1</button></li>
<li>test <button class='right'>button2</button></li>
<li> <ul>
<li>test <button class='right'>button3</button></li>
<li>test <button class='right'>button4</button></li>
</ul></li>
<li><ul>
<li>test <button class='right'>button6</button></li>
<li>test <button class='right'>button6</button></li>
</ul>
</li>
</ul>
CSS
.right {
position:absolute; right:10px; top:2px;
}
li{ width:100%; position:relative; padding:5px 0;}
see fiddle
Add to your CSS:
li { clear: right; }
This will also work:
.right {
float: right;
clear: right;
}
Updated JSFiddle: http://jsfiddle.net/1ha04a3r/5/
the alignment is very wired because you are using "float:right" in css. remove it then it will work and you can use the css class to modify your list padding and position.
HTML Code
<ul>
<li>test <button class='right'>button1</button></li>
<li>test <button class='right'>button2</button></li>
<ul>
<li>test <button class='right'>button3</button></li>
<li>test <button class='right'>button4</button></li>
<ul>
<li>test <button class='right'>button6</button></li>
<li>test <button class='right'>button6</button></li>
</ul>
</ul>
</ul>
css
li{ width:100%; padding:2px auto;}
*you can use position relative
Related
I have tried and researched many ways but I couldn't find out how to align unordered list in center. it seems like the bullets are not connected to the text and stay still.
here is the html code:
<ul id="facts">
<li>fact 1</li>
<li>fact 2</li>
<li>fact 3</li>
</ul>
and this is the css code:
#facts {
text-align: center;
}
the result will be like
You can use list-style-position: inside; to set the bullets in front of the text like this:
#facts {
text-align: center;
list-style-position: inside;
}
<ul id="facts">
<li>fact 1</li>
<li>fact 2</li>
<li>fact 3</li>
</ul>
You can put your Unordered List in an element with the class of .container and define .container like this:
.container{
width:100%;
display:flex;
flex-direction:column;
align-items:center;
}
<div class="container">
<ul>
<li>Lorem</li>
<li>Ipsum</li>
<li>Dolor</li>
<li>Set</li>
</ul>
</div>
Code seems to be correct, but simply doesn't work.
html of it
<div class="logo5">
<a class="underlogolink" id="expandlogonav" href="whatever.com" >
<div class="underlogotext alcenter">{{settings.underlogotext}}</div>
</a>
</div>
<div class="logo6" id="underlogonav">
<ul>
<li>Test 1</li>
<li>Test 2</li>
<li>Test 3</li>
<li>Test 4</li>
<li>Test 5</li>
</ul>
</div>
and the css
#underlogonav {
height:0px;
overflow-y:hidden;
-webkit-transition:0.5s;
-moz-transition:0.5s;
-ms-transition:0.5s;
-o-transition:0.5s;
transition:0.5s;
}
#expandlogonav:hover ~ #underlogonav {
height:auto;
}
Could you please point me to where i went wrong.
#underlogonav is not a sibling of #expandlogonav.
You need to have a selector that actually matches the element.
You could hover over the div containing #expandlogonav instead.
NB: If you fix that, the transition still won't work because you can't transition to auto heights.
I want to have my Bootstrap tabs flush with my page header (mock shown below), but having the header taller than the other tabs causes everything to break. How can I do this?
<ul class="nav nav-tabs" role="tablist">
<li><h1>Header</h1></li>
<li class="active">Tab 1</li>
<li>Tab 2</li>
<li>Tab 3</li>
<li class="pull-right"><button id="new-thing" class="btn btn-primary">New</button></li>
</ul>
Here is the font size and margin spacing I want. Now I just need the tabs flush with the bottom border.
http://jsfiddle.net/bK4a4/4/
Delete margin
li h1 { margin: 0}
After Edit Options
add margin-top to other elements. fiddle
add line-height to h1 fiddle
Try adding this to your CSS:
.nav-tabs h1 {
font-size: 20px !important;
margin-top: 10px !important;
margin-right: 5px !important;
}
You can change the font size, weight and margins to fit your needs.
in your html , make a class for the header
<li><h1 class="header">Header</h1><li>
and in your csss
html, body {
padding: 1em;
}
.header {
margin:0;
padding:0;
padding-right:10px;
}
Here is the jsfiddle to check it out : jsFiddle Sample
How about something like that:
<ul class="nav nav-tabs" role="tablist">
<li><div style=" font-size:25px">Header  </div></li>
<li class="active">Tab 1</li>
<li>Tab 2</li>
<li>Tab 3</li>
<li class="pull-right"><button id="new-thing" class="btn btn-primary">New</button></li></ul>
where you use inline css to specify the font size and margin
I have a list with emails in a <ul> element:
email 1
email 2
email 3
email 4
And I want to show this list items in vertical like I write before, but I also want my email 1 and email 2 in horizontal like:
email 1 / email 2
email 3
email 4
I already try use a class with display:inline but dont work!
Somebody there already did something like this and know how I can do it?
I have this html:
<footer id="footer-container">
<section id="footer1">
<div id="col">
<h1>Contacts</h1>
<ul>
<li class="email">email 1</li>
<li class="email">email 2</li>
<li class="email">email 3</li>
<li class="email">email 4</li>
</ul>
</div>
</section>
</footer>
And this Css:
#footer-container
{
width:100%;
float:left;
background:brown;
}
#footer1
{
width:480px;
margin:0 auto 0 auto;
}
#footer1 ul
{
/*list-style:none*/
}
#footer1 ul li
{
margin:0 0 7px 0;
}
#footer1 ul li a
{
text-decoration:none;
color:#ccc;
font-size:15px;
}
#col
{
float:left;
margin:10px auto 0 auto;
width:480px;
}
http://jsfiddle.net/JJSLZ/
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 here.
Is there any reason you can't simply change the HTML to put email 1 and email 2 in the same <li>?
Example:
<ul>
<li>email 1 / email 2</li>
<li>email 3</li>
<li>email 4</li>
<li>email 5</li>
</ul>
I am making a list with a heading and subheadings. My main list, Home1, is followed by a subheading. How can I exactly position the subheading content without affecting another list?
<div id="wrapper">
<ul id="testnav">
<li>
Home
<ul id="subnav">
<div style=" float : left; width :70%;" >
<li>Sub Heading</li>
<li>Sub Heading</li>
<li>Sub Heading</li>
</div>
<div STYLE="float : left; width :30%; height:900px;">
Sub Heading Content
</div>
</ul>
</li>
<li>Home2</li>
<li>Home3</li>
<li>Home4</li>
<li>Home5</li>
</ul>
</div>
#testnav {
list-style: none;
padding: 0;
marigin: 10px 10px 10px 0;
width: 900px;
}
#subnav {
list-style: none;
padding: 0;
marigin: 10px 10px 10px 0;
width: 300px;
}
I'm having a hard time understanding the question, but looking at your markup I see that you have a DIV as a direct descendant of a UL. Only LI elements can be children of UL.
<ul id="subnav">
<div style=" float : left; width :70%;" > <!-- THIS DIV CANNOT BE HERE -->
<li>Sub Heading</li>
<li>Sub Heading</li>
<li>Sub Heading</li>
</div> <!-- THIS DIV CANNOT BE HERE -->
<div STYLE="float : left; width :30%; height:900px;"> <!-- THIS DIV CANNOT BE HERE -->
Sub Heading Content
</div> <!-- THIS DIV CANNOT BE HERE -->
</ul>
Also, ul > div is not valid HTML.
The first step to solving your problem is making sure your markup is correct as Andy Ford suggested. Secondly, making sure your spelling of the CSS in the code is correct may help.
From what I can decipher from your question, you're trying to make sure that #subnav is absolutely positioned relative to #testnav.
<ul id="testnav">
<li>
Home
<ul id="subnav">
<li>Sub Heading</li>
<li>Sub Heading</li>
<li>Sub Heading</li>
</ul>
</li>
<li>Home2</li>
<li>Home3</li>
<li>Home4</li>
<li>Home5</li>
</ul>
#testnav, #subnav { list-style:none; padding:0; }
#subnav {
position: absolute;
width: 300px;
}
I am not sure if that's what you want, but generally the first step to figuring out what's going wrong with CSS is to remove every extraneous addition you can.