Border doesn't adapt to list-style: none; - html

I'm currently working on designing my site, and at the moment I'm trying to sketch down the pricing elements of my SaaS. I want to have a border around my divs, but my problem is that the border goes where the list style "is", even though I have written it to be none. Or at least I think that is the error. I have no clue how to fix this! What am I doing wrong here?
Here is my HTML code:
<div id='pricing_plan2' class="grid_4">
<ul class="plan">
<li class="plan_price2">
<span id="recommend">WE RECOMMEND</span><BR />
<span class="dollar">$</span>
<span class="price">14.99</span>
<span class="month">/month</span>
</li>
<li class="plan_title2">
STANDARD ACCOUNT
</li>
<li class="features">1GB storage</li>
<li class="features">5GB bandwith</li>
<li class="features">2 domains</li>
<li class="features">3 databases</li>
<li class="features">1 FTP account</li>
<li class="features">25 Email Accounts</li>
<li class="buynow">Choose standard plan</li>
</ul>
here is the CSS:
body {
background-color: #fff;
}
#recommend {
color: #becdd6;
}
.plan_title {
background: #ecf2f6;
padding:20px;
color: #000;
text-align: center;
border-bottom: 1px solid #d9dee1;
letter-spacing: 2px;
font-weight: bold;
}
.plan_price {
color: #479ccf;
background: #ecf2f6;
text-align: center;
padding: 10px 0 0 0;
}
.dollar {
font-size: 25px;
}
.price {
font-size: 45px;
font-weight: bold;
}
.month {
font-size: 15px;
}
.features {
background:blue;
}
.features:nth-child(odd){
background: none repeat scroll 0 0 #F7F7F7;
font-size: 13px;
font-weight: bold;
padding: 10px 5px;
}
.features:nth-child(even){
background: none repeat scroll 0 0 #fff;
font-size: 13px;
font-weight: bold;
padding: 10px 5px;
}
.buynow {
background: #ecf2f6;
text-align: center;
padding: 15px;
}
.buynow a {
padding: 10px;
color: #FFF;
background-image:url('../img/btn-bg.png');
border: 1px solid #5c9439;
text-decoration: none;
}
#pricing_plan1 ul, #pricing_plan2 ul, #pricing_plan3 ul {
list-style: none;
font-family: "Helvetica Neue";
border: 1px solid #d9dee1;
}
Also if somebody sees things here that could be improved, I would love to hear it. If there are something I can shorten down, or write better for example.

Add padding-left: 0 to your ul style declaration.
#pricing_plan1 ul, #pricing_plan2 ul, #pricing_plan3 ul {
list-style: none;
font-family: "Helvetica Neue";
border: 1px solid #d9dee1;
padding-left: 0px;
}
<ul> has default left padding, and that's the reason of your code output.
Check jsFiddle demo. Both lists have list-style set to none, but only the second one has additional left-padding: 0. As you can see, the first one has exactly the same problem you're trying to solve.

ul
{
padding:0px;
margin:0px;
}

Related

Clickable list items with two fields: a serial number and a name

I have a simple list of names organized into a element. List elements now purely consist of names, e.g. Agnes, Billy, Bob. Each of them are clickable. Example code (also available at this link):
#myList {
width: 50vw;
margin:1vw;
background:#666;
}
#myUL {
list-style-type: none;
height: 30vw;
overflow-y: auto;
}
#myUL li a {
border: 1px solid #ddd;
background-color: #f6f6f6;
padding: 0.75vw 0.75vw 0.75vw 0.75vw;
text-decoration: none;
font-size: calc(12px + 0.2vw);
color: black;
display: block;
}
#myUL li a:hover {
background-color: #eee;
}
<div id="myList">
<ul id="myUL">
<!-- <li>
<a href="#">
1
Adele
</a>
</li> -->
<li>1Agnes</li>
<li>Billy</li>
<li>Bob</li>
<li>Calvin</li>
<li>Dan</li>
<li>Eleanor</li>
<li>Erica</li>
<li>Freddie</li>
</ul>
</div>
Now I would like to improve design in such a way that each list item have a serial number (i.e. 1, 2, 3, etc.) in a separate box in the same line. A picture is worth a thousand words, so here is what I am planning to create:
Importantly, I don't want to logically separate the serial number from the name itself, as these are still to be treated as one unit and hence they must be clickable together. For example replacing this:
<li>Agnes</li>
by this:
<li>1Agnes</li>
is incorrect, as the <a> tag for the number "1" and the <a> tag for the name "Agnes" are no longer related, no longer clickable together.
Hence, my idea was to keep the <a> tags and create two <div>s within like so:
<li><div class="serial_num">1</div><div class="name">Agnes</div></li>
Now I believe I'm not far from the intended result, yet I didn't manage to figure it out. I assume the display property is among the ones to tinker with here, but I didn't succeed.
Full example of my current output can be viewed here.
You need to set display: inline-block;
.serial_num {
width: 5%;
margin-right: 0.5vw;
text-align: center;
border: 3px solid #ddd;
font-weight: 800;
font-size: 3vw;
display: inline-block;
}
.name {
border: 3px solid #ddd;
display: inline-block;
}
I believe this is what you're going for
li {
list-style-type: none;
border: 1px solid #c1c1c1;
background-color: #f6f6f6;
padding: 5px;
}
li a {
text-decoration: none;
color: #000;
}
a .serial_num, a .name {
display: inline;
padding: 5px;
}
a .serial_num {
border-right: 1px solid #c1c1c1;
padding-right: 10px;
}
a:hover {
text-decoration: underline;
}
<li>
<a href="#">
<div class="serial_num">1</div>
<div class="name">Agnes</div>
</a>
</li>
You could use flexbox:
#myList {
width: 50vw;
background: #666;
}
#myUL {
list-style-type: none;
padding: 0;
height: 30vw;
overflow-y: auto;
}
#myUL li a {
color: black;
text-decoration: none;
display: flex;
align-items: center;
background-color: white;
border: 1px solid gray;
border-bottom: none;
}
#myUL li:last-of-type a {
border-bottom: 1px solid gray;
}
.name {
flex-grow: 1;
}
.serial_num {
font-weight: bolder;
font-size: 1.5rem;
border-right: 1px solid gray;
}
.serial_num,
.name {
padding: .75rem;
}
#myUL li a:hover {
background-color: #eee;
}
<div id="myList">
<ul id="myUL">
<li><span class="serial_num">1</span><span class="name">Agnes</span></li>
<li><span class="serial_num">2</span><span class="name">Agnes</span></li>
<li><span class="serial_num">3</span><span class="name">Agnes</span></li>
<li><span class="serial_num">4</span><span class="name">Agnes</span></li>
<li><span class="serial_num">5</span><span class="name">Agnes</span></li>
</ul>
</div>
You can use display: flex on the a tag with span tags between and then style each column name serial_num individually to suit your needs.
* {
padding: 0;
margin: 0;
}
#myList {
width: 45vw;
font-family: Helvetica, Arial, Sans-Serif;
font-weight: 500;
}
#myUL {
list-style-type: none;
height: 30vw;
overflow-y: auto;
}
#myUL li a {
background-color: #f6f6f6;
text-decoration: none;
font-size: calc(12px + 0.2vw);
color: black;
display: flex;
}
#myUL li a:hover {
background-color: #eee;
font-weight: bolder;
}
.name {
width: 100%;
}
.serial_num {
text-align: center;
min-width: 15%;
font-weight: bold;
font-size: calc(12px + 0.3em);
}
.serial_num, .name{
border: 1px solid #ddd;
padding: 0.75vw 0.75vw 0.75vw 0.75vw;
}
<div id="myList">
<ul id="myUL">
<li><div class="serial_num">1</div><div class="name">Agnes</div></li>
<li><span class="serial_num">55</span><span class="name">Billy</span></li>
<li><span class="serial_num">188</span><span class="name">Bob</span></li>
<li><span class="serial_num">255</span><span class="name">Calvin</span></li>
<li><span class="serial_num">260</span><span class="name">Dan</span></li>
<li><span class="serial_num">360</span><span class="name">Eleanor</span></li>
<li><span class="serial_num">555</span><span class="name">Erica</span></li>
<li><span class="serial_num">1000</span><span class="name">Freddie</span></li>
</ul>
</div>
Here is your fiddle updated: Updated fiddle

Borders around menu items disappearing

I'm having another issue. I can't figure where the issue is. I had added a border around my menu items. Everything was working fine until I added a logo. I believe the issue is with my .Main-Nav li a:hover. in my CSS. I'll post everything and see if you guys can figure it out. I would also like to know if I need to make a different file for every page on my website
* {
margin: 0PX;
padding: 0PX;
}
header {
background-image: linear-gradient(rgba(0, 0, 0, 0.5), rgba(0, 0, 0, 0.5)), url(https://static.pexels.com/photos/371794/pexels-photo-371794.jpeg);
height: 100vh;
background-size: cover;
background-position: center;
}
.main-nav {
float: right;
list-style: none;
margin-top: 30px;
}
.main-nav li {
display: inline-block;
}
.main-nav li a {
color: white;
text-decoration: none;
padding: 5px 20px;
font-family: "roboto", sans-serif;
font-size: 15px;
}
.main-nav li.active a {
border: 1px solid white;
}
.main-nav li a:hover {
border: 1px solid white;
}
.logo img {
width: 200px;
height: auto;
float: left;
}
body {
font-family: monospace;
}
.row {
max-width: 1200px;
margin: auto;
}
.hello {
position: absolute;
width: 1200px;
margin-left: 0px;
margin-top: 0px;
}
h1 {
color: white;
text-text-transform: uppercase;
font-size: 70px;
text-align: center;
margin-top: 275px;
}
.button {
margin-top: 30px;
margin-left: 440px;
}
.btn {
border: 1px solid white;
padding: 10px 30px;
color: white;
text-decoration: none;
margin-right: 5px;
font-size: 13px;
text-transform: uppercase;
}
.btn-one {
background-color: darkorange;
font-family: "roboto", sans-serif;
}
.btn-two {
font-family: "roboto", sans-serif;
}
.btn-two:hover {
background-color: darkorange;
transition: all 0.5s ease-in;
}
<HTML>
<Head>
<title> Drew's Blog</title>
<link href="style.css" rel="stylesheet" type "text/css" </head>
<body>
<header>
<div class="row">
<div class="logo">
<img src="https://upload.wikimedia.org/wikipedia/commons/3/3a/Oh-deer.png">
</div>
<ul class="main-nav">
<li class="active"> HOME </li>
<li> ABOUT </li>
<li> GALLERY </li>
<li> NEWS </li>
<li> CONTACT </li>
<li> LESSONS </li>
</ul>
</div>
<div class="Hello">
<h1> Lets Get Started</h1>
<div class="button">
Get to Know Me
Check out my lessons
</div>
</header>
</body>
</html>
`
In
.main-nav li a {
color: white;
text-decoration: none;
padding: 5px 20px;
font-family: "roboto", sans-serif;
font-size: 15px;
}
Add a:
border: 2px solid white;
This will put a border around your menu items that are put in the <li> tag
Look in the active class for the border:
.main-nav li.active a {
border: 2px solid white;
}
That's for the HOME button, because it's class is active (class="active">) and it already had a border
I changed the pixels so I can see the results, but the problem is exactly that: The pixels. If your hover pixels and li pixels are the same, you won't see any change
This should add a border to your menu items and change when you hover over them with the mouse.
Also, the
.main-nav li a:hover
does the exact opposite. When you define a border here and you HOVER OVER A MENU ITEM, a border will APPEAR, so basically try to balance the pixels out.
And I'm trying to figure out what exactly you want. Do you want borders to always be there and when you hover over them you want them to disappear or do you want borders to appear when you hover over them.

Bullet points appearing in navigational menu with the addition of list-style-type: none

I've been having issues with adding CSS to a UL and still having the bullet points showing up.
this is my html code
<div id="menu">
<ul>
<li> تماس با ما</li>
<li>درباره ما</li>
<li> آرشیو ویدئو</li>
<li>آرشیو سرودها و منابع پرستشی</li>
<li>خانه</li>
</ul>
</div>
and this is my CSS
<style>
#menu {
width: 780px;
height: 40px;
font-size: 13px;
font-family: Tahoma, Geneva, sans-serif;
font-weight: bold;
text-align: center;
text-shadow: 3px 2px 3px #333333;
background-image: url("images/Menu_Background.jpg");
border-radius: 9px;
}
#menu li {
list-style:none;
list-style-type:none;
display: inline;
padding: 20px;
}
#menu ul {
height: auto;
padding: 8px 0px;
margin: 0px;
}
#menu a {
text-decoration: none;
color: #fff;
padding: 8px 8px 8px 8px;
}
#menu a:hover {
color: #F90;
background-color: none;
}
</style>
I've read many other forums and questions that were asked on Stackoverflow and the solution was to add the `list-style-type=none; but when I added that I am still having the same issue.
here is my URL to the site http://khaneyeparastesh.com/indexHomeNew.htm
list-style-type is not your issue. When you enter the code you've provided on a JS Fiddle there are no bullets. I believe that you are referring to the red "bullet" points that are showing on your website. These are a result of this style:
li a {background: url(images/bull.gif) 0 7px no-repeat;}
Remove that and the red bullets will be gone.

CSS: Only part of my menu are supposed to hide

I'm trying to hide part of my menu. When I call display:none The entire menu disappears. I have id's to separate them so I don't get why this happens. Here's the code:
HTML:
<ul id="menu">
<li>Categories 1
<ul id="cat1">
<li>temp1</li>
<li>temp2</li>
<li>temp3</li>
</ul>
</li>
</ul>
CSS:
#menu {
background-color: #0000FF;
height: 20px;
padding: 15px 0 10px;
margin-bottom: 20px;
font: 12px 'DroidSansBold', Tahoma,sans-serif;
font-weight: bold;
text-transform: uppercase;
letter-spacing: 1px;
box-shadow: 3px 2px 3px #000;
border-radius: 5px;
text-align: center;
}
#menu li{
display: inline-block;
}
#menu li a {
color: #fff;
text-decoration: none;
margin: 0 120px;
}
#cat1 li{
display: block;
padding: 10px;
}
#cat1 li a{
background-color: #0000FF;
padding: 10px;
border-radius: 5px;
}
Somewhat working demo: http://jsfiddle.net/ZfN7t/
When you're dealing with ul inside ul, it's usually easier to style if you give them different classes:
<ul id="menu">
<li class="menu-item">Categories 1
<ul id="cat1">
<li class="cat1-item">temp1</li>
<li class="cat1-item">temp2</li>
<li class="cat1-item">temp3</li>
</ul>
</li>
</ul>
Hide the temp1, temp2, temp3 like this:
.menu-item #cat1{
display:none;
}
To display on hover:
.menu-item:hover #cat1{
display:block;
}

Center navbar and add top/bottom-borders

I want to center (automatically) the navbar on this site. Also, I need to have a 1px border-top and 1px border-bottom that extends roughly 70% of the nav area.
It should look like this mockup once it's done:
Remove the floats on your li tags, and on your #navigation, add text-align: center;. Your floats are making your parent have a height of 0, which will in turn not allow you to have your borders. This fixes both those issues. From there, just add border-top: 1px solid white; border-bottom: 1px solid white; to your ul to get your lines.
Take a look at this fiddle http://jsfiddle.net/qZTAt/
The key there is this piece of code:
nav {
border-top: 1px solid #fff;
border-bottom: 1px solid #fff;
margin: 0 15%;
text-align: center;
}
Try using margin:0 auto; padding:0;
Right I'm going to come in late to this party (with an already answered question!) just to add what I would have done. It's based on this technique here
http://jsfiddle.net/rabmcnab/GSSQx/
<body>
<header>
<h1 class="font"> Heading</h1>
<nav>
<ul>
<style> body {
font-family: 'Poiret One', cursive;
font-weight: bold;
font-size: 20px;
}
.font {
font-family: 'Poiret One', cursive;
}
header {
background-color: aqua;
padding: 40px 0px;
}
ul {
list-style-type: none;
}
li {
display: inline-block;
padding: 0 40px;
margin: 0 auto;
text-align: center;
}
nav {
border-top: thin solid white;
border-bottom: thin solid white;
width: 50%;
margin: 0 auto;
}
h1 {
text-align: center;
margin-top: -10px;
color: white;
font: 40px/0 arial;
padding: 40px 0;
}
li:hover {
color: #fff;
cursor: pointer;
}
</style>
<link href="https://fonts.googleapis.com/css?family=Poiret+One" rel="stylesheet">
<body>
<header>
<h1 class="font"> Heading</h1>
<nav>
<ul>
<li>Wedding</li>
<li>Engagement</li>
<li>Services</li>
</ul>
</nav>
</header>
</body>
</html>
<li>Wedding</li>
<li>Engagement</li>
<li>Services</li>
</ul>
</nav>