style specific unordered list without affecting other ul's - list

This is doing my nut in and ruining my weekend.
I found this great expandable jquery vertical navigation menu. The problem is on other pages i have unordered lists and the unordered list style for the jquery vertical menu effects all the other unordered lists and i dont want that.
The html and inline css etc is this..........
ul{list-style: none; padding: 0; margin: 0;}
#nav {float: left; width: 280px; border-top: 1px solid #999; border-right: 1px solid #999; border-left: 1px solid #999; margin: 15px 0;}
#nav li a {display: block; padding: 10px 15px; background: #ccc; border-top: 1px solid #eee; border-bottom: 1px solid #999; text-decoration: none; color: #000;}
#nav li a:hover, #nav li a.active {background: #999; color: #fff;}
#nav li ul {display: none;}
#nav li ul li a {padding: 10px 25px; background: #ececec; border-bottom: 1px dotted #ccc;}
<ul id="nav">
<li>Item 1
<ul>
<li>Sub-Item 1 a</li>
<li>Sub-Item 1 b</li>
<li>Sub-Item 1 c</li>
</ul>
</li>
<li>Item 2
<ul>
<li>Sub-Item 2 a</li>
<li>Sub-Item 2 b</li>
</ul>
</li>
<li>Item 3
<ul>
<li>Sub-Item 3 a</li>
<li>Sub-Item 3 b</li>
<li>Sub-Item 3 c</li>
<li>Sub-Item 3 d</li>
</ul>
</li>
<li>Item 4
<ul>
<li>Sub-Item 4 a</li>
<li>Sub-Item 4 b</li>
<li>Sub-Item 4 c</li>
</ul>
</li>
</ul>
i tried changing the css ul to #nav ul{list-style: none; padding: 0; margin: 0;} but this doesnt seem to work. please help this me out someone. cheers.
teddy

Usually, when you download a JQuery widget or thingamabob, it comes in a folder, with an example on how to use it! But i'm only guessing here that you didn't get this straight from JQuery UI?
In any case, try wrapping your menu into a DIV, with ID = "Nav"...
your other UL's inside your pages should then inherit the default ul style you declare above.

Related

Change submit button position in form

I am developing a form using Html and CSS. I have used grid to place my textboxes. But the problem I am facing is position of submit button. It is placed next to last textbox but I want it to be placed on the separate line at the end.
The complete code of my this form is:
<!DOCTYPE HTML>
<html>
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Form practice</title>
<style>
.container{
max-width: 1000px;
margin-left: auto;
margin-right: auto;
padding: 1em;
}
.wrapper{
box-shadow: 0 0 20px 0 rgba(72,94,116,0.7);
}
.wrapper > *{
padding: 1em;
}
.form-heading{
background-color: grey;
}
.form-heading h3{
text-align: center;
}
.contact form{
display: grid;
grid-template-columns: 1fr 1fr 1fr;
grid-gap: 10px;
}
.contact form label{
display: block;
}
.contact form p{
margin: 0;
}
.contact form .submit-btn{
grid-column: 25%;
}
.contact form button, .conntact form input{
width: 100%;
padding: 1em;
border: 1px solid;
}
.contact input[type=text]{
height: 30px;
width: 90%;
}
.contact form button{
background-color: grey;
color: white;
border: 0;
text-transform: uppercase;
}
.contact form button:hover, .contact form button:focus{
background-color: silver;
color: black;
outline: 0;
/*transition: background-color 1s ease-out; */
}
</style>
</head>
<body>
<div class="container">
<div class="wrapper">
<div class="form-heading">
<h3>Form</h3>
</div>
<div class="contact">
<form>
<p>
<label>First Name</label>
<input type="text" name="firstName">
</p>
<p>
<label>Last Name</label>
<input type="text" name="lastName">
</p>
<p>
<label>Email Address</label>
<input type="text" name="email">
</p>
<p>
<label>Phone Number</label>
<input type="text" name="phone">
</p>
<p class="submit-btn">
<button>Submit</button>
</p>
</form>
</div>
</div>
</div>
</body>
</html>
Please help me in this regard. Thank you for your help.
This does the trick in your case.
.submit-btn {
grid-row-start: 3;
grid-column-start: 3;
grid-column-end: 3;
}
But a few suggestions:
Change your <p> with <div>. <p> is for paragraphs of text.
Don't use grid for displaying a grid. It's very unflexible and makes stuff hard to read. Use display: flex instead. If you want to see a sample on how to use flex to display a grid you might wanna check out the Bootstrap grid system. (Basic grid and implementation for form. Actual Bootstrap CSS)
There is no real reason to invent your own grid system at all. Bootstrap's Grid system is just one of many already working grids. :)
You Should Follow This Grid Layout Documentatoin for manage form element into specific position.

Hovering over link

When hovering over an item how do I make it so the border wont change?
In the css I don't do anything to the borders,
#ALink:hover #SubMenu {
display: block;
position: relative;
top: 20px;
left: -18px;
}
As you can see in this JSFiddle, when you hover over A the border extends to the submenu. How do I make it not happen? (keep the border where it is)
JSFiddle
You are making #SubMenu visible, and SubMenu is wrapped in #ALink. When you make a child visible, parent re-sizes to show child element.
One solution can be as following. Of course you need to cleanup your css and make it beautiful again:
<a id="ALink" href="#">
<label>A</label>
<ul id="SubMenu">
<li class="items-2">Item 1</li>
<li class="items-2">Item 2</li>
<li class="items-2">Item 3</li>
</ul>
</a>
a > label {
display: block;
padding-left: 17px;
margin-top: 5px;
line-height: 40px;
font-size: 20px;
border: 1px solid #4f5058;
font-family: Helvetica, Arial, sans-serif;
font-weight: bold;
color: #f3f3f3;
}
Check it out: http://jsfiddle.net/Zuct2/1/

Navigation Menu: Using a single centered image w/ 2 menu links on either side

Ok, I'm trying to tinker with my navigation menu. I want something like this website:
http://aleksfaure.com/
He has a single image (logo) centered with 2 menu links on either side. I've tried a couple of different things, including just using my logo as an image centered at the top, in between the menu. No dice.
Here's the relevant HTML and CSS I have with my current nav menu. I'm still kind of a intermediate beginner at this.
HTML
<nav role="navigation">
<ul id="nav">
<li>Home</li>
<li>About Me</li>
<ul id="nav-right" style="float:right;">
<li>Portfolio</li>
<li>Contact</li> </ul>
</ul></nav>
CSS
#header nav {
position: relative;
width: 700px;
height: 163px;
display: block;
margin: 0 auto;
text-align: center;
}
#header nav ul li {
float: left; list-style: none;
}
ul#nav li a {
display: block;
width: 100px;
height: 100px;
padding: 50px 0 0 0;
margin: 0 10px 0 10px;
font-family: 'MuseoSlab-500', Helvetica, sans-serif;
font-size: 16px;
text-transform: uppercase;
color: #000;
text-shadow: 0 2px 1px #bbbaba;
text-decoration: none;
}
ul#nav li a.mainnav:hover {
color: #13cad1;
text-shadow: 0 2px 1px #fff;
}
You don't need to use two separate lists. Treat the entire menu, including your image, as one list. Consider something like this for your HTML:
<div>
<ul id="nav">
<li>Home</li>
<li>About Me</li>
<li><img src="images/yourLogo.png"></li>
<li>Portfolio</li>
<li>Contact</li>
</ul>
</div>
And make sure you have your style set to float: left;
#nav li { float: left; list-style: none;}
Then, just center the entire div on the page, and style your links as you want.
SEPARATE NOTES:
In your code, you are missing the closing tag for your first unordered list.
The navigation element is not very widely supported, so depending on your audience you may want to use a div.

How can I add image/div in ul submenu already using a background image?

http://www.dunhamssports.com/wp-content/themes/ds2/css/images/pic.png
I am trying to add a red bar at the bottom of each submenu in a list I am building. Since the current sub menu ul is outputting the dark gradient background I cannot use another background image. Having trouble figuring out where in my code I might be able to trick it to appear at the bottom of each list in the submenu.
<div id="nav">
<ul id="coolMenu">
<li>Home</li>
<li>Products
<ul>
<li>Home</li>
<li>Products</li>
<li>Store Locator</li>
<li>Weekly Circular Locater</li>
</ul>
</li>
<li>Store Locator
<ul>
<li>Home</li>
<li>Products</li>
<li>Store Locator</li>
<li>Weekly Circular Locator</li>
</ul>
</li>
<li>Weekly Circular</li>
</ul>
</div>
body {background-color:#999;}
#nav {background: url(http://www.dunhamssports.com/wp-content/themes/ds2/css/images/nav.jpg) repeat-x scroll 0 0 transparent; border-bottom: 1px solid #010103; height: 46px;}
ul {list-style-type:none; padding:0px; margin:0px; font-family:Arial, Helvetica, sans-serif; font-size:16px; line-height:36px; text-transform:uppercase;}
#coolMenu {float: left;list-style: none;margin:0px; font-size: 14px;}
#coolMenu > li {float: left;margin:10px 0px 0px 10px; border-right:1px solid #fff;padding-right:7px;}
#coolMenu li a {display: block; line-height: 2em; padding: 0 .5em; text-decoration: none;}
#coolMenu ul {position: absolute;display: none;z-index: 999;list-style-type:none;}
#coolMenu ul li a {width: 100%;}
#coolMenu li:hover ul {display: block;}
/* Main menu
------------------------------------------*/
#coolMenu > li > a {color:#fff;font-weight: normal;}
#coolMenu > li:hover > a {color: #fff; border-bottom:9px solid #920001;}
#coolMenu > li > .active {color: #fff;}
/* Submenu
------------------------------------------*/
#coolMenu ul {border: 1px solid #fff; background-image:url(http://www.dunhamssports.com/wp-content/themes/ds2/css/images/dropnav-bg.png); background-repeat:repeat;text-transform:none; color:#fff; list-style-type:disc; padding-left:25px;}
#coolMenu ul li a {color: #fff; text-indent:-10px;}
#coolMenu ul li:hover a {color: #999;}
You can put in a div into the last li so you can then adjust it there like this,
<ul id="coolMenu">
<li>Home</li>
<li>Products
<ul>
<li>Home</li>
<li>Products</li>
<li>Store Locator</li>
<li>Weekly Circular Locater
<div></div>
</li>
</ul>
</li>
<li>Store Locator
<ul>
<li>Home</li>
<li>Products</li>
<li>Store Locator</li>
<li>Weekly Circular Locator
<div></div></li>
</ul>
</li>
<li>Weekly Circular</li>
</ul>
And then put in this style,
#coolMenu ul li div {
border-bottom:9px solid #920001;
width: auto;
margin-left: -20px;
}

CSS3 box-shadow on <li> element not working

I have a grid of 12 boxes created from an unordered list as below. Border radius works fine, but IU can't get the shadow to appear. Does the box-shadow property only work on divs, but not display block elements?
<ul id="treatments">
<li id="eyelash"></li>
<li id="massage"></li>
<li id="tanning"></li>
<li id="facials"></li>
<li id="waxing"></li>
<li id="tinting"></li>
<li id="threading"></li>
<li id="nails"></li>
<li id="makeup"></li>
<li id="hair"></li>
<li id="courses"></li>
<li id="bespoke"></li>
</ul>
#content #treatments li {
height: 125px;
width: 125px;
display: block;
float: left;
margin-right: 13px;
margin-bottom: 13px;
-moz-box-shadow: 1px 1px 2px #777;
-webkit-box-shadow: 1px 1px 2px #777;
box-shadow: 1px 1px 2px #777;
-moz-border-radius: 8px;
border-radius: 8px;
behavior: url(/scipts/PIE.php);
}
Be sure that the margin of <li> is not set to zero.
The box-shadow is rendered in the margin. No margin -> no shadow.
You shouldn't have any issues with using box-shadow on li elements since box-shadow can be applied to all elements. Here's the section on box-shadow on the W3C site.
I had same problem... box-shadow didn't work... The reason was in rbga instead of rgba in my css code! :D