So it's the first time I use CSS (been looking through some documentation) and I have this problem.
I created a navigation menu, a horizontal one on the right side, and I want to have the website title on the left side, inline with it. I tried a few things, but it either gets it up and moves the menu lower, or places it under the menu.
Last thing I tried worked but it seems that I can't use the padding-top property anymore (however, I can use padding-left). I would be grateful if any of you could help me with this last thing. Thank you!
The CSS code: (it's messy, I know, as I said, my first one :) )
ul {
list-style-type: none;
margin: 0;
padding: 0;
overflow: hidden;
position: relative;
padding-top: 10px;
padding-right: 50px;
}
li {
float: right;
font-family: 'Raleway';
font-size: 20px;
}
a {
display: block;
padding: 20px;
background-color: transparent;
color: black;
text-align: center;
padding: 14px 16px;
text-decoration: none;
}
a:hover {
color: orangered;
}
/* Logo */
#logo {
float: left;
display: inline-block;
position: relative;
padding-left: 200px;
padding-top: -250px;
font-family: 'Raleway';
font-size: 30px;
}
/* Fonts */
#font-face {
font-family: Raleway;
src: url(/css/fonts/raleway.ttf);
}
First, you can't put a <p> inside a <ul>.
You can achieve what you want by putting the logo inside a <li> and use float:left;.
ul {
list-style-type: none;
margin: 0;
padding: 0;
overflow: hidden;
position: relative;
padding-top: 10px;
padding-right: 50px;
}
li {
float: right;
font-family: 'Raleway';
font-size: 20px;
}
a {
display: block;
padding: 20px;
background-color: transparent;
color: black;
text-align: center;
padding: 14px 16px;
text-decoration: none;
}
a:hover {
color: orangered;
}
/* Logo */
#logo {
float: left;
font-size: 30px;
}
/* Fonts */
#font-face {
font-family: Raleway;
src: url(/css/fonts/raleway.ttf);
}
<ul>
<li id="logo">Cluj</li>
<li>CONTACT</li>
<li>IMAGINI</li>
<li>STIRI</li>
<li>EVENIMENTE</li>
<li>ACASA</li>
</ul>
Related
still learning flexbox. I can´t find the reason about how the items on the nav element are not vertically aligned with the h1 text. Would love some help! Link for the codepen at the end.
The expected result should be both the nav and the h1, inside the .main-header, vertically aligned.
HTML:
<div class="container">
<header class="main-header clearfix">
<h1>📘 The Code Magazine</h1>
<nav>
<!-- <strong>This is the navigation</strong> -->
Blog
Challenges
Flexbox
CSS Grid
</nav>
</header>
</div>
CCS:
* {
/* border-top: 10px solid #1098ad; */
margin: 0;
padding: 0;
box-sizing: border-box;
}
body {
color: #444;
font-family: sans-serif;
border-top: 10px solid #1098ad;
position: relative;
}
.main-header {
background-color: #f7f7f7;
/* padding: 20px;
padding-left: 40px;
padding-right: 40px; */
padding: 20px 40px;
margin-bottom: 60px;
/* height: 80px; */
}
nav {
font-size: 18px;
/* text-align: center; */
}
h1,
h2,
h3 {
color: #1098ad;
}
h1 {
font-size: 26px;
text-transform: uppercase;
font-style: italic;
}
a:link {
color: #1098ad;
text-decoration: none;
}
a:visited {
/* color: #777; */
color: #1098ad;
}
a:hover {
color: orangered;
font-weight: bold;
text-decoration: underline orangered;
}
a:active {
background-color: black;
font-style: italic;
}
nav a:link {
/* background-color: orangered;
margin: 20px;
padding: 20px;
display: block; */
margin-right: 30px;
display: inline-block;
}
.main-header {
display: flex;
align-items: center;
}
Here is the link for the codepen:
https://codepen.io/Swanbe/pen/OJzpjor
Thanks in advance!
For past 10 minutes, I have been debugging your code.
Wrote another code like this to see if the problem persists. But that was vertically aligned.
So I dug deeper and tried changing and tags. Nothing Great.
....
Until I just removed that blue rubber(Emoji or whatever you call that ) and added a property in nav.
nav {
height: 100px;
display: flex;
flex-direction: row;
align-items: center;}
and that's it.
Try removing that emoji and see if it helps.
my problem is that i have styled my navigation bar with a block/button style graphic. that works just fine it's just when i put any tags it resorts to that styling? is there a way on the css style sheet to stop that style and having a different one. i've had this problem on other pages too, but it didnt end up being a problem. can anyone help?
css:
nav {
position:relative;
z-index:3;
position: absolute;
margin-left: 420px;
margin-top: -15px;
float: right;
}
ul {
list-style-type: none;
margin-top: 2px; padding: 0;
overflow: hidden;
}
li {
float: left;
margin-top: 0px;
}
a:link,a:visited {
display: block;
width: 100px;
height: 25px;
font-weight: bold;
font-size: 12px;
color: #000000;
background-image: url(images/buttonreg.png);
text-align: center; padding-top: 5px;
text-decoration: none;
font-variant: small-caps;
}
a:hover,a:active {
color: #FFAA50;
background-image: url(images/buttonhover.png);
}
html: just an unordered list
<nav>
<ul>
<li>home</li>
<li>about</li>
<li>portfolio</li>
<li>services</li>
<li>contact</li>
</ul>
</nav>
It's not clear what your question is, but I'm sure what you want to do is easy enough. Sounds like you need to add a class or ID to your elements, or to make your CSS more specific. E.g.
nav ul {
list-style-type: none;
margin-top: 2px; padding: 0;
overflow: hidden;
}
nav li {
float: left;
margin-top: 0px;
}
nav a:link,a:visited {
display: block;
width: 100px;
height: 25px;
font-weight: bold;
font-size: 12px;
color: #000000;
background-image: url(images/buttonreg.png);
text-align: center; padding-top: 5px;
text-decoration: none;
font-variant: small-caps;
}
nav a:hover,a:active {
color: #FFAA50;
background-image: url(images/buttonhover.png);
}
Simply make your CSS selector more specific by making it only select <a> elements that are descendants of <nav>:
nav a:link,
nav a:visited {
display: block;
width: 100px;
height: 25px;
font-weight: bold;
font-size: 12px;
color: #000000;
background-image: url(images/buttonreg.png);
text-align: center; padding-top: 5px;
text-decoration: none;
font-variant: small-caps;
}
nav a:hover,
nav a:active {
color: #FFAA50;
background-image: url(images/buttonhover.png);
}
I have read posts at StackOverflow.
As I understand icons are managed as text.
I. But bullets are inside class where are icon fonts.How to change color of icons not text?
I try to change source but it did not work.
src:url('fonts/icomoon.eot?#iefix-ggg507') format('embedded-opentype'),
I have bullets like:
<li class="icon-checkmark2">
<b>Text1</strong><b>
text2
</li>
II. How to define style, weight for my text as I have removed source CSS elements like :
font-style: normal;
font-weight: normal;
font-variant: normal;
but text is still not from body specifications. It seems like style will be ruined when there are icon fonts.
There are a variety of ways to handle this.
I've grabbed a few examples from the web and posted them in this FIDDLE.
CSS
.holder {
float: left;
width: 100px;
height: 100px;
border: 1px solid black;
}
ul {
width: 300px;
margin: 20px auto;
}
.ul1 li {
color: red;
}
.ul1 li span {
color: green;
}
.ul2 li {
list-style-image:url('http://jmcivor.com/icons/akuma2.png');
}
.ul3 li {
list-style-type: square;
}
.ul4 {
list-style-type: none;
}
.ul4 li:before {
content: "4";
font-family: "webdings";
color: red;
}
.ul5 li {
padding-left: 5px;
margin-bottom: 10px;
list-style-type: none;
border-left: 5px solid green;
}
.ul6 li {
list-style-type: none;
}
.ul6 li:before {
content: "";
line-height: 1em;
width: .5em;
height: .5em;
background-color: blue;
float: left;
margin: .25em .25em 0;
border-radius: 50%;
}
I am trying to create a vertical menu that looks like this (think of the cubes as placeholders for icons):
http://i.stack.imgur.com/dWWzR.png
I am having trouble putting the description below the main text, which is an <a> of course. Here is what I have so far in the HTML code:
<div id="actions">
<ul>
<li>Element 1<span class="desc">Description</span></li>
<li>Element 2<span class="desc">Description</span></li>
</ul>
</div>
And the CSS looks like this:
#actions {
width: 200px;
height: 60px;
padding: 10px 25px 10px 25px;
}
#actions ul {
list-style-type: none;
}
#actions ul li {
list-style-type: none;
display: block;
margin-top: 10px;
border: 2px solid;
height: 60px;
background-color: #64ADD0;
}
#actions a {
display: inline-block;
padding-left: 5px;
padding-right: 5px;
text-decoration: none;
font-weight: bold;
line-height: 40px;
}
#actions a:hover {
color: #3CA0D0;
}
#actions .desc {
display: inline-block;
line-height: 20px;
}
However, the result is that the description appears to the right of the link, and furthermore, the <span> isn't part of the link, so it shows as an ordinary label. How can I fix this? I am new to CSS and web design in general so please excuse me if this is a dumb question. :)
Thanks!
just remove the inline in your inline-block; that will make the anchor take up the whole line and push anything after it to the next line.
#actions a {
display: block;
padding-left: 5px;
padding-right: 5px;
text-decoration: none;
font-weight: bold;
line-height: 40px;
}
http://jsfiddle.net/LmbLR/
Just add the follow CSS rule
#actions > ul > li > a {
display: block;
}
Here's the DEMO
I tend to use float:left and clear:both in order to know exactly where the objects are located: http://jsfiddle.net/MAt8Y/
#actions .desc {
line-height: 20px;
float:left;
clear:both;
padding-left: 5px;
padding-right: 5px;
}
#actions a {
display: inline-block;
padding-left: 5px;
padding-right: 5px;
text-decoration: none;
font-weight: bold;
line-height: 40px;
float:left;
}
So I have a menu from ul and li, and it looks something like this at page load:
but when i click each menu and executed the code this happens:
what should i do? here's my CSS:
#menu-centered {
padding: 0px;
margin-bottom: 0px;
}
#menu-centered ul {
margin: 0;
padding: 0;
height: 99px;
width: 603px;
}
#menu-centered li {
display: inline;
list-style: none;
padding: 0px;
background: url(images/menu1.png) no-repeat right top;
}
#menu-centered a {
border-style: none;
border-color: inherit;
border-width: medium;
display: block;
margin-right: 0;
padding: 20px 30px 0px 30px;
text-decoration: none;
font-family: Arial, Helvetica, sans-serif;
font-size: 16px;
font-weight: normal;
color: #FFFFFF;
height: 68px;
width: 130px;
text-align: center;
}
#menu-centered a:hover {
background: url(images/menu2.png) no-repeat right top;
}
and here's my html code for the menus:
<div id="menu-centered">
<ul>
<li> <a href="javascript:Clikbtn1()" >MENU1</a></li>
<li>MENU2</li>
<li>MENU3</li>
</ul>
</div>
Please help. Thanks
Your menus need some LoVe and HAte. In other words you need to create all four of the important link pseudoselectors to avoid letting browsers destroy your layout by applying the default active pseudoslector.
Define a:link, a:visited, a:hover and a:active for your menu, in that order exactly.