I'm trying to get a horizontal list formatted so the image is on the left side of the ul. Here's an idea of what I'm aiming for (green is the image, the x,y,z labels are to help refer to portions of each part if it helps):
But I can't seem to figure out how to keep my image 'separate' from the text part of the ul.
HTML:
<span class='row'>
<ul class = 'top-ul'>
<ul id="menu">
<li><h2><u>Colby Abbott</u></h2></li><br>
<li><p id="email">Enos.Goyette#hotmail.com</p></li><br>
<li><p id="phoneNumber">360.751.0915</p></li>
<li><img src=https://i.imgur.com/9ZC02Oss.jpg ></li>
</ul>
<ul id="menu">
<li><h2><u>Jamaal Powlowski</u></h2></li><br>
<li><p id="email">Stan.Roberts48#gmail.com</p></li><br>
<li><p id="phoneNumber">(057) 629-2042 x2604</p></li>
<li><img src=https://i.imgur.com/9ZC02Oss.jpg ></li>
</ul>
<ul id="menu">
<li><h2><u>Ubaldo Bode</u></h2></li><br>
<li><p id="email">Alia.Lynch52#gmail.com</p></li><br>
<li><p id="phoneNumber">881.886.7822 x87177</p></li>
<li><img src=https://i.imgur.com/9ZC02Oss.jpg ></li>
</ul>
<ul id="menu">
<li><h2><u>Herbert Bailey</u></h2></li><br>
<li><p id="email">Arnaldo73#gmail.com</p></li><br>
<li><p id="phoneNumber">1-620-830-6732</p></li>
<li><img src=https://i.imgur.com/9ZC02Oss.jpg ></li>
</ul>
</ul>
<br>
</span>
<span class='row'>
<ul>
<ul id="menu">
<li><h2><u>Alana Legros</u></h2></li><br>
<li><p id="email">John.Nienow37#hotmail.com</p></li><br>
<li><p id="phoneNumber">299.276.2872 x90430</p></li>
<li><img src=https://i.imgur.com/9ZC02Oss.jpg ></li>
</ul>
<ul id="menu">
<li><h2><u>Gertrude Jacobs</u></h2></li><br>
<li><p id="email">Erna_Krajcik94#gmail.com</p></li><br>
<li><p id="phoneNumber">(335) 097-2437</p></li>
<li><img src=https://i.imgur.com/9ZC02Oss.jpg ></li>
</ul>
<ul id="menu">
<li><h2><u>Ellis Homenick</u></h2></li><br>
<li><p id="email">Ezra_Stamm76#yahoo.com</p></li><br>
<li><p id="phoneNumber">(391) 333-5140</p></li>
<li><img src=https://i.imgur.com/9ZC02Oss.jpg ></li>
</ul>
</ul>
</span>
CSS:
ul {
width:100%;
table-layout: fixed;
}
ul ul {
list-style-type: none;
margin: 0;
padding: 0;
overflow: hidden;
display: inline-block;
table-layout: fixed;
border: 3px red solid;
width:20%;
}
li img{ /* I want to move this to the right of the ul it's in somehow */
display: inline;
border: 3px solid green;
}
p {
margin:0px;
padding-left: 10px;
}
.row{
width: 100%;
}
.row li{
display:inline-block;
}
But it turns out like this.
How could I 'break apart' the image, so the text stays center (or top) aligned, with the image to the right; while also having the border be tighter around each ul?
Edit: I'm new to html/css, so if there's a better way to format this generally, please let me know. Per below, it was mentioned to use a list to do this ...so the above is my attempt but it's likely I'm not thinking of something else that'd be better.
FWIW, I tried doing this as a table, but was recommended to use a list instead
If you really insist on using your semantics, this is the solution I can come up with with the least possible changes in your code.
HTML
<ul class="menu"> #change id to class
<li> #placed all the info you want on the left to a single li element
<h2><u>Colby Abbott</u></h2>
<p id="email">Enos.Goyette#hotmail.com</p>
<p id="phoneNumber">360.751.0915</p>
</li>
<li> #right side
<img src=https://i.imgur.com/9ZC02Oss.jpg >
</li>
</ul>
CSS
ul.menu {
border: 3px red solid;
width: 400px;
}
ul.menu li {
list-style-type: none;
margin: 0;
padding: 0;
overflow: hidden;
float:left;
}
ul.menu li img{
display: inline;
border: 3px solid green;
float: right;
width: 100px;
}
Then repeat this for all your sections.
Side note: I also removed the <br>s at the end of your li elements because they're unnecessary. I highly suggest reading up on Flexbox because it does exactly what you want.
Related
So I'm learning to make websites in html and css. recently i encountered the error which didn't happened to me before: then i adding border to link in css, i cant get bottom and top borders to appear (that's a huge issue because i want to use border-bottom)
a.navi:link{color: black;}
a.navi:hover{color: black;
border-bottom: 5px solid #0ecf5b;}
#navigation li{
display: inline-block;
font-family: Courier New;
font-style: italic;
font-size: 32px;
padding: 5px 25px;
background: #ffffff;
/*border-bottom: 5px solid #0ecf5b;*/
}
however if I'm adding border-bottom: to navigation li{} im getting this border
(#navigation li{} is list items surrounded by
<a href="..." class="navi">
tags)
Html code:
<nav id="navigation">
<ul>
<li>Home</li>
<li>Some-Stuff</li>
<li>About</li>
<li>Contacts</li>
<li>Others</li>
</ul>
</nav>
Put your <a> tags inside your <li> tags.
For example:
<li>Home</li>
Here is a working example: https://jsfiddle.net/kb3su8og/
I'm assuming you want your links underlined, which would be better if you created a div underneath the link and the colored that appropriately, but to do borders try something like this for your html:
<nav id="navigation">
<ul class="navi">
<li>Home</li>
<li>Some-Stuff</li>
<li>About</li>
<li>Contacts</li>
<li>Others</li>
</ul>
and have your css reflect the changes with:
navi > a:hover {
border-bottom //that stuff
What that does is when a link is hovered over it does whatever you want. I am away from my computer so I can not test the code but I think this will work if not there are tons of youtube tutorials on this exact matter. Have a nice day!
Make sure you are using <a> tag inside <li> tag, it should be
<nav id="navigation">
<ul>
<li>Stuff</li>
</ul>
</nav>
ul{list-style:none;}
a{display:block;text-decoration:none;}
li{display:inline-block;}
li:hover > a{color: black;border-bottom: 5px solid #0ecf5b;}
#navigation a{
font-family: Courier New;
font-style: italic;
font-size: 32px;
padding: 5px 25px;
}
<nav id="navigation">
<ul>
<li>Stuff</li>
<li>Stuff</li>
<li>Stuff</li>
</ul>
</nav>
I think the more standard way to do what you want would be to put your a tags inside your li's, and use styles to make sure they fill the whole space, such as display: block.
ul {
list-style: none;
width: 200px;
}
li a.navi {
display: block;
padding: 5px;
border: 1px solid black;
cursor: pointer;
text-align: center;
}
li a.navi:hover {
background-color: #cccccc;
}
<ul>
<li><a class="navi">One link</a></li>
<li><a class="navi">Second link</a></li>
</ul>
This may not be the style you are going for, I'm just guessing based on the snippet you provided.
On my page i've got a navbar with logo, several items and login section which is aligned to the right.
<div id="topbar">
<nav>
<ul>
<li>
<a ui-sref="home" class="home-logo">
<img src="http://placehold.it/350x150">
</a>
</li>
<li> Item1</li>
<li> Item2</li>
<li> Item3</li>
</ul>
<ul>
<li> Log In</li>
<li>
Sign up for free
</li>
</ul>
</nav>
</div>
I try to make this login section to be aligned vetically on the same height as the remaining menu elements, but floating takes these items out of the normal flow and I've got no idea how do I achieve this?
Here's what I'm talking about: http://codepen.io/anon/pen/grBXJa
Used to line-height as like this
#topbar li
{
line-height:150px;
}
ul
{
list-style: none;
}
#topbar
{
font-size: 1.75em;
}
#topbar ul
{
padding: 0;
display: inline-block;
}
#topbar img
{
vertical-align: middle;
margin-right: 60px;
}
#topbar li
{
display: inline-block;
margin-right: 60px;
line-height:150px;
}
#topbar ul:last-child
{
padding: 0;
float: right;
}
<div id="topbar">
<nav>
<ul>
<li>
<a ui-sref="home" class="home-logo">
<img src="http://placehold.it/350x150">
</a>
</li>
<li> Item1</li>
<li> Item2</li>
<li> Item3</li>
</ul>
<ul>
<li> Log In</li>
<li>
Sign up for free
</li>
</ul>
</nav>
</div>
The layout I want to achieve is the following, one large image with a gallery of four thumbnails below it:
I'm using a Javascript gallery to actually display a full screen gallery, activated when clicking on this element.
The problem is that the gallery script expects the images as direct children in an unordered list, all of them including the one that is the big image in my layout:
<ul>
<li data-src="img1.jpg">
<img src="thumb1.jpg" />
</li>
<li data-src="img2.jpg">
<img src="thumb2.jpg" />
</li>
</ul>
The first <li> is the big image, all the others are small thumbnails.
Is there a way to achive my desired layout while still having all the images in the unordered list? If I could break up the list this would be easy, but that wouldn't be recognized by the gallery script anymore.
Is it possible to achive this layout without changing the underlying structure of the list?
I suggest using float: left and display: block on li, and float: none on li:first-child:
ul
{
margin: 0;
padding: 0;
list-style-type: none;
}
li
{
margin: 2px 5px;
display: block;
float: left;
}
li:first-child
{
float: none;
}
<ul>
<li>
<img src="http://lorempixel.com/g/430/430/" />
</li>
<li>
<img src="http://lorempixel.com/g/100/100/" />
</li>
<li>
<img src="http://lorempixel.com/g/100/100/" />
</li>
<li>
<img src="http://lorempixel.com/g/100/100/" />
</li>
<li>
<img src="http://lorempixel.com/g/100/100/" />
</li>
</ul>
Simple and clean, no JS involved.
This is my attempt based on flexbox. The skewed images are a side effect of taking random cat images from the web, and constraining them to a certain width and height (fiddle).
The CSS:
ul {
padding: 0;
margin: 0;
}
ul {
display: flex;
flex-wrap: wrap;
list-style: none;
}
li {
/** add box-sizing: border-box; if you include padding or borders **/
}
li:first-child {
width: 100%;
height: 500px;
}
li:not(:first-child) {
/** add box-sizing: border-box; if you include padding or borders **/
width: 25%; /** use calc if you include margins **/
height: 100px; /** whatever height you want **/
}
li > img { /** demo only - because of image sizes **/
width: 100%;
height: 100%;
}
The HTML:
<ul>
<li data-src="whatever">
<img src="http://www.gordonrigg.com/the-hub/wp-content/uploads/2015/06/little_cute_cat_1920x1080.jpg" />
</li>
<li data-src="whatever">
<img src="http://rufflifechicago.com/wp-content/uploads/cat-treats.jpg" />
</li>
<li data-src="whatever">
<img src="http://www.vetprofessionals.com/catprofessional/images/home-cat.jpg" />
</li>
<li data-src="whatever">
<img src="http://animalia-life.com/data_images/cat/cat8.jpg" />
</li>
<li data-src="whatever">
<img src="http://www.catprotection.com.au/wp-content/uploads/2014/11/5507692-cat-m.jpg" />
</li>
</ul>
You are looking for some simple CSS, there are multiple ways to approach this, the easiest is likely:
<style type="text/css">
ul.thumbs li{
float:right;
}
</style>
<ul class="thumbs">
<li data-src="img1.jpg">
<img src="thumb1.jpg" />
</li>
<li data-src="img2.jpg">
<img src="thumb2.jpg" />
</li>
</ul>
you could also set the ul to display:table-row and the lis to display:table-cell which would allow them to evenly spread and fill the space allowed in the ul
Based on your edit you will need something a little more complicated, without knowing which plugin you are using, or how it works, you can try this approach (uses a little jQuery):
$(document).ready(function(){
$('li').click(function(){
$(this).parent().find('.selected').removeClass('selected');
$(this).addClass('selected');
});
});
ul{
padding-top:405px;
position:relative;
}
li{
height:100px;
width:100px;
float:left;
background:blue;
}
li.selected{
background: red;
position: absolute;
top: 0;
height: 400px;
width: 400px;
}
<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.10.0/jquery.min.js"></script>
<ul>
<li class="selected">test 1</li>
<li>test 2</li>
<li>test 3</li>
<li>test 4</li>
<li>test 5</li>
</ul>
I am trying to make a navigation bar with a four columns submenus. I coded most of things, but when I creating the submenu I found the problem.
This is my HTML:
<div id="navigation">
<ul>
<li class="current">
Home
</li>
<li class="sub-menu">
Our Products
<div class="subnav product">
<div class="content">
<div class="col">
<ul>
<li class="one">
Main Menu Item
</li>
<li class="one">
Main Menu Item
</li>
<li class="one">
Main Menu Item
</li>
</ul>
</div>
<div class="col">
<ul>
<li class="two">
<img src="" />
Promoting Peace in the Niger Delta
</li>
<li class="three">
<img src="" />
Promoting Peace in the Niger Delta
</li>
<li class="four">
<img src="" />
Promoting Peace in the Niger Delta
</li>
<li class="five">
<img src="" />
Promoting Peace in the Niger Delta
</li>
</ul>
</div>
</div>
</div>
</li>
<li class="">
Service Maintenance
</li>
<li class="sub-menu">
Frequently Ask Questions
<li class="sub-menu">
Our Products
<div class="subnav product">
<div class="content">
<div class="col">
<ul>
<li class="one">
Main Sub Item
</li>
<li class="one">
Main Sub Item
</li>
<li class="one">
Main Sub Item
</li>
</ul>
</div>
</div>
</div>
</li>
</ul>
</div>
Hope somebody will help me out.
Thank you.
The problem is the container width is defined at 300px
#navigation ul li > div.product {
width: 300px;
}
And its child elements are taking up 100% of that space. So you need to make sure they have room to float left.
#navigation div.col {
float: left;
height:200px;
width: 25%;
}
Hopefully that helps with your question.
Fiddle
Check this http://jsfiddle.net/qtvVK/11/embedded/result/.
I made some changes to your markup and used display:inline-block; instead of floating elements
Relevant CSS syles
/* Dropdown styles */
#navigation ul > li > ul.sub-menu {
display: none;
position:absolute;
padding:10px 0;
background:#fff;
border: 1px solid #DDDCDC;
top: 24px;
z-index: 1;
}
/* Show dropdown when hover */
#navigation ul > li:hover > ul.sub-menu {
display:block;
}
.row {
width:auto;
white-space: nowrap;
}
.col {
display: inline-block;
vertical-align: top;
padding: 0 10px;
}
i suggest using jQuery.
it has simple function called slideDown().
Here is a link to a good tutorial.
You should do like so: First hide your menu when script starts:
$("#idOfDropDownMenu").hide();
And command to drop menu down when mouse enters button and slide up when it leaves it:
$("#idOfButton").hover(function(){ //function that fires when mouse enters
$("#idOfDropDownMenu").slideDown();
}, function() { //function that fires when mouse leaves
$("#idOfDropDownMenu").slideUp();
}
Instead of using IDs you can use any CSS selector.
I hope this helps with your question.
css
ul li ul
{
display: none;
position: fixed;
margin-left: 191px;
margin-top: -37px;
}
ul li:hover ul
{
display: block;
}
ul li a:hover
{
color: #fff;
background: #939393;
border-radius:20px;
}
ul li a
{
display: block;
padding: 10px 10px;
color: #333;
background: #f2f2f2;
text-decoration: none;
}
ul
{
background: #f2f2f2;
list-style:none;
padding-left: 1px;
width: 194px;
text-align: center;
}
html
<ul>
<li>Home</li>
<li>
About
<ul>
<li>About Me
<li>About Site
</ul>
</li>
<li>Contact</li>
</ul>
On http://www.elitedeafpoker.com/dev/index.html on the navbar there is a little gray indicator icon underneath "PLAYERS" when I hover the (class) sub-menu area and it will not display the white indicator icon. http://www.elitedeafpoker.com/dev/img/indicator-hover.png is an image showing two icons in one image (you cannot see the white icon there).
CSS
.nav-collapse_ .nav > li.sub-menu:after {
position: absolute;
top: 100px;
left: 50%;
display: block;
margin-left: -4px;
width: 8px;
height: 3px;
background: url(../img/indicator-hover.png) 0 0;
content: '';
}
.nav-collapse_ .nav > li.sub-menu:hover {
background: url(../img/indicator-hover.png) 0 -10px;
}
HTML
<div class="nav-collapse nav-collapse_ collapse">
<ul class="nav sf-menu clearfix">
<li class="sub-menu">PLAYERS
<ul>
<li>EDPS PLAYERS</li>
<li>PLAYERS OF THE MONTH</li>
<li>PLAYERS OF THE YEAR</li>
</ul>
</li>
<li>SHOP</li>
<li>NEWS & EVENTS</li>
<li>FOUNDERS</li>
<li>CONTACT US</li>
</ul>
</div>
I believe your
.nav-collapse_ .nav > li.sub-menu:hover
Should be changed to
.nav-collapse_ .nav > li.sub-menu:hover:after
to fix this issue