UL class not working? Only LI works? - html

I just started HTML/CSS two days ago.. Please go easy on me. I'm currently building a website. For some reason, I cannot get the the HTML class/id to render with CSS. To make it work, I have to make a class for each list. How do I make it so that the class for ul as a whole? (When I take out the <li class="name_here>, all the styles don't work anymore)
HTML
<div>
<ul class="navi">
<li class="navi"><img src="../images/bestfoodservicesweb_07.jpg" width="104" height="67" />
<img src="../images/bestfoodservicesweb_09.jpg" width="105" height="67" />
<img src="../images/bestfoodservicesweb_11.jpg" width="110" height="67" />
<img src="../images/bestfoodservicesweb_13.jpg" width="105" height="66" /></li>
</ul>
</div>
<div>
<div>
<ul class="lastbit">
<li><img src="../images/bestfoodservicesweb_34.jpg" width="85" height="29"/></li>
<li><img src="../images/bestfoodservicesweb_37.jpg" width="62" height="16" /></li>
<li><img src="../images/bestfoodservicesweb_38.jpg" width="69" height="16" /></li>
<li><img src="../images/bestfoodservicesweb_39.jpg" width="100" height="16" /></li>
</ul>
<ul class="lang">
<li class="lang"><img src="../images/bestfoodservicesweb_41.jpg" width="29" height="14" /></li>
<li class="lang"><img src="../images/bestfoodservicesweb_43.jpg" width="39" height="17" /></li>
</ul>
<ul class="social">
<li class="social"><img src="../images/bestfoodservicesweb_27.jpg" width="30" height="29" /></li>
<li class="social"><img src="../images/bestfoodservicesweb_29.jpg" width="30" height="29" /></li>
<li class="social"><img src="../images/bestfoodservicesweb_31.jpg" width="30" height="29" /></li>
</ul>
</div>
</div>
CSS
.navi {
list-style: none;
display: inline;
margin-left: 5px;
position: relative;
top: 5px;
}
.lastbit {
list-style: none;
display: inline-block;
}
.lang {
list-style: none;
display: inline;
}
.social {
list-style: none;
display: inline;
}

You should read up more on selectors in CSS. In a nutshell what you are doing with this:
.social {
list-style: none;
display: inline;
}
is saying that everything with the class social gets the given styles applied to it.
When you have that class on each of the li elements it applies as you want. However when you are putting that class on the ul it is applying the styles to the ul and not the li. To fix this you need to specify that you want the styles on the li by changing the selector slightly:
.social li {
list-style: none;
display: inline;
}
The above says that all li elements that are descendents of items with class social should have the styles which is what you want.

Not exactly sure what you are trying to do, but you might try something like this.
.lastbit li {
list-style: none;
display: inline-block;
}
Your markup can then be:
<ul class="lastbit">
<li></li>
...
</ul>
This will apply the style to all the li elements of the ul you mark with that style.

To style all lists, use:
ul{
/* styles here */
}
To style all of the items in the list, use
li{
/* styles here */
}
To style all of the anchors in all of the items in the list, use
li a{
/* styles here */
}
Also, just so you're aware, your first ul has the class name "navi" and so do the items within the list. It also only has one <li>, although you likely want 4 (since you have 4 links in it).

Related

CSS class canceled text-align property

I changed CSS Class so my other list doesn't run the same code by CSS but the text-align code in the first code didn't run and I don't know why
I tried to put p tag and align right but it doesn't work, I also tried to put align attribute in "a" tag and it doesn't run too. I tried to put text-align attribute in CSS and it also doesn't run. But, only the text-align property which doesn't work. The rest of the CSS is fully working.
here's my CSS code:
.navbar-text ul{
flex: 1;
text-align: right;
}
.navbar-text ul li{
display: inline-block;
list-style: none;
margin: 0 25px;
}
.navbar-text ul li a{
text-decoration: none;
color: #000;
padding: 0 10px;
width: 100%;
position: relative;
}
And here's my HTML code:
<div class="navbar-text">
<ul>
<li>Home</li>
<li>About</li>
<li>Contact</li>
</ul>
</div>
And this:
<ul>
<li><img src="instagram.png" alt=""></li>
<li><img src="twitter.png" alt=""></li>
</ul>

HTML Footer styling

I would like to know if it would be possible to move my footer to the bottom of the page rather then display on the side like it is here Image essentially I want it to function like most other elements and always display below the element above it.
here is the code I used
<div style="border:3px solid black;width:800px;float:left;margin:5%"><center><h1>Builder</h1><br><p style="padding-left:5%;padding-right:5%">We are looking for someone who can offer their building skills and abilities to a passionate team.</p></center></div>
<div style="border:3px solid black;width:800px;float:left;margin:5%"><center><h1>Plugin Developer</h1><br><p style="padding-left:5%;padding-right:5%">Are you passionate about programming? Well if you are we would like your help on Plugin Development!.</p></center></div>
<!--End of body!-->
<footer>
<style>
.mar {
margin-left:10px;
margin-right:10px;
}
</style>
<ul>
<li><img src="Images/Discord.png" alt="Discord" height="35px" width="35px" class="mar"></li>
<li><img src="Images/Instagram.png" alt="Instagram" height="35px" width="35px" class="mar"></li>
<li><img src="Images/Youtube.png" alt="YouTube" height="35px" width="50px" class="mar"></li>
<li><img src="Images/Twitter.png" alt="Twitter" height="35px" width="35px" class="mar"></li>
</ul>
Try to add this code.
<style>
ul{
float:left;
width:100%;
display:inline-block;
}
li{
width: 25%;
float: left;
display: inline-block;
list-style: none;
}
</style>
Try this code
CSS:
footer {
width: 100%;
display: inline-block;
}
footer ul li {
display: inline-block;
}

Align multiple unordered lists on the same line

I want to put multiple <ul> on the same line, simulating products in a shop. So far I've got multiple unordered list tags:
ul {
display: inline;
}
li {
list-style: none;
}
<ul>
<li><img src="http://au.alexu.edu.eg/English/Academics/PublishingImages/Central%20Library%20Logo%20Design%20-%20English.png" width="20%" height="20%" /></li>
<li>Name</li>
<li>Author</li>
</ul>
<ul>
<li><img src="http://au.alexu.edu.eg/English/Academics/PublishingImages/Central%20Library%20Logo%20Design%20-%20English.png" width="20%" height="20%" /></li>
<li>Name</li>
<li>Author</li>
</ul>
How can I accomplish this? I have them show vertically but I dont want them this way.
You could set it to ul {display:inline-block;}.
Be aware of width="20%" height="20%" on the image in your example, it may give you unwanted results. As percentage width or height is always relative to container's width, not itself.
For simplicity, I just use fixed width in the demo below.
ul {
display: inline-block;
vertical-align: top;
padding-left: 0;
}
li {
list-style: none;
}
<ul>
<li><img src="//dummyimage.com/100"></li>
<li>Name</li>
<li>Author</li>
</ul>
<ul>
<li><img src="//dummyimage.com/100"></li>
<li>Name</li>
<li>Author</li>
</ul>
Use CSS:
li{
float:left;
}
floating left will fix it..

css drop down menu - "hiding" nested menu items

I'm trying to create a drop down menu, however I'm having difficulty "hiding" the nested menu items. The links and styling work fine, it's just the drop-down effect that I've missed something on. Ideas?
jsfiddle
css-
#header .social {
float: right;
list-style: none;
padding-top: 20px;
}
#header .social ul li {
display: inline;
position: relative;
}
#header .social ul li ul {
display: none;
}
#header .social ul li a {
display: inline;
padding-left: 6px;
white-space: nowrap;
}
#header .social ul li:hover ul {
display: inline;
position: absolute;
}
#header .social ul li:hover li {
float: none;
}
html/php-
<div class="social">
<ul>
<li><img src="<?php bloginfo('template_url');?>/img/instagram.png" alt="cait and shannon barker instagram" /></li>
<ul>
<li>cait</li>
<li>shannon</li>
</ul>
<li><img src="<?php bloginfo('template_url');?>/img/youtube.png" alt="cait and shannon barker youtube" /></li>
<ul>
<li>cait</li>
<li>shannon</li>
</ul>
<li><img src="<?php bloginfo('template_url');?>/img/facebook.png" alt="cait and shannon barker facebook" /></li>
<ul>
<li>cait</li>
<li>shannon</li>
</ul>
<li><img src="<?php bloginfo('template_url');?>/img/twitter.png" alt="cait and shannon barker twitter" /></li>
<ul>
<li>cait</li>
<li>shannon</li>
</ul>
<li><img src="<?php bloginfo('template_url');?>/img/pinterest.png" alt="cait and shannon barker lockerz" /></li>
<ul>
<li>cait</li>
<li>shannon</li>
</ul>
</ul>
</div><!-- end social -->
Is this what you are looking for ? http://jsfiddle.net/cScrD/3/
The HTML structure was not standard (ul should not be ideally put as a child of another ul. Rather open an li tag and put the ul inside the li). The structure should ideally be like this.
<div id="header">
<div class="social">
<ul>
<li><img src="<?php bloginfo('template_url');?>/img/instagram.png" alt="cait and shannon barker instagram" /><!-- li should not end here -->
<ul>
<li>cait</li>
<li>shannon</li>
</ul>
</li><!-- li should end here -->
</ul>
</div>
</div>

Centering a List with HTML and CSS

Hope someone can help me, I am trying to center my gallery (list items) and I feel I have tried everything and nothing is working, if someone could point me in the right direction it would much appreciated.
http://www.jamessuske.com/thornwood/gallery.php
HTML CODE
<div class="gallery">
<ul>
<li><img src="pics/icon1.jpg" border="0" /></li>
<li><img src="pics/icon2.jpg" border="0" /></li>
<li><img src="pics/icon3.jpg" border="0" /></li>
<li><img src="pics/icon4.jpg" border="0" /></li>
<li><img src="pics/icon5.jpg" border="0" /></li>
<li><img src="pics/icon6.jpg" border="0" /></li>
<li><img src="pics/icon7.jpg" border="0" /></li>
<li><img src="pics/icon8.jpg" border="0" /></li>
CSS CODE
.gallery{
width:965px;
float:right;
}
.gallery ul{
list-style-type:none;.gallery li{
float:left;
text-align:center;
}
.gallery ul a {
display:block;
text-decoration: none;
color:#FFF;
padding:5px 0 0 5px;
}
Centering child elements can be done like this:
Apply text-align:center to the parent element
Remove any floats from children and apply or ensure that the display is inline or inline-block
So something like this:
.gallery ul {
text-align:center;
}
.gallery li {
float:none; /* or just make sure you don't float them */
display:inline-block;
}
Should work for you, if your goal is to center the images but have them in rows.
Can't do it with float left:
Example http://jsfiddle.net/HerrSerker/KvPPe/
.gallery{
width:965px;
}
.gallery ul{
list-style-type:none;
text-align:center
}
.gallery li{
display: inline-block;
}
* html .gallery li { /* IE6 */
display: inline;
}
*:first-child + html .gallery li { /* IE7 */
display: inline;
}
.gallery ul a {
display:block;
text-decoration: none;
color:#FFF;
padding:5px 0 0 5px;
}
You are going to continue to have significant problems with all this because you don't have a doctype and you are in 'quirks mode'. Add this to your very first line: <!DOCTYPE html>.
However, by adding the doctype, this may change the whole layout. But that's the cost of not starting off properly.