CSS add slogan into header - html

I have a header consists of a website name (at the left part) and a horizontal navigation menu (at the right part). My objective is to add a slogan under the site name. Meanwhile, the bottom of site name should still completely match with the bottom of menu elements, the only change is adding slogan.
Here are my header and a picture with expected result: https://jsfiddle.net/1nc9ch3x/1/
Give me please a hint how to figure it out. Thank you in advance!
body {
background: url(http://i.imgur.com/Asbdvgw.png);
font-family: 'Open Sans', sans-serif;
}
header {
width: 950px;
margin: auto;
position: relative;
background: #fff;
overflow: hidden;
}
.wrapper {
width: 950px;
margin: 0 auto;
}
header .logo {
display: inline;
border-left: 1px dashed #333333;
padding: 0 0 25px 10px;
text-decoration: none;
float: left;
font-size: 30px;
color: #cc3333;
margin: 25px 0px;
}
header nav {
float: right;
margin: 25px 0px;
}
header nav ul {
margin-top: 0px;
}
header nav ul li {
display: block;
float: left;
}
header nav ul li a {
text-decoration: none;
color: #333333;
font-size: 17px;
padding-top: 15px;
padding-bottom: 15px;
transition: all .2s linear;
-webkit-transition: all .2s linear;
-moz-transition: all .2s linear;
-o-transition: all .2s linear;
}
header nav ul li a.active,
header nav ul li a:hover {
color: #cc3333;
border-top: 1px dashed #cc3333;
border-bottom: 1px dashed #cc3333;
}
header li {
display: inline;
border-left: 1px dashed #cc3333;
padding: 10px 25px 10px 25px;
}
header li:first-child {
border: none;
}
<header>
<div class="wrapper">
<div class="logo">
Name
</div>
<nav>
<ul>
<li>Category 1
</li>
<li>Category 2
</li>
<li>Category 3
</li>
<li>Category 4
</li>
</ul>
</nav>
</div>
</header>
<br>
<br>
<center><font color="#fff">My goal:</font>
<br>
<br>
<img src="http://i.imgur.com/aW7k0QI.png">

This should do the trick : Fiddle : https://jsfiddle.net/1nc9ch3x/3/
HTML :
<div class="logo">
Name<span>Slogan</span>
</div>
CSS :
header .logo {
position:relative;
}
header .logo span {
white-space:nowrap;
color:black;
font-size:18px;
position:absolute;
bottom:0;
left:10px;
}

To achieve what you want is as easy as putting the following code inside <div class="logo">:
<p id = "slogan">Slogan should be right here</p>
Then, you can go in your CSS file and make the necessary changes for #slogan. Something like the following:
#slogan {
color: #0c0c0c;
font-size: 16px;
display: block;
margin-top: 5px;
}
You can check out this working demo or the following snippet.
Snippet:
body {
background: url(http://i.imgur.com/Asbdvgw.png);
font-family: 'Open Sans', sans-serif;
}
header {
width: 100%;
height: 100px;
margin: auto;
position: relative;
background: #fff;
overflow: hidden;
}
.wrapper {
width: 950px;
margin: 0 auto;
}
header .logo {
display: inline;
border-left: 1px dashed #333333;
padding: 0 0 25px 10px;
text-decoration: none;
float: left;
font-size: 30px;
color: #cc3333;
margin: 25px 0px;
}
header nav {
float: right;
margin: 25px 0px;
}
header nav ul {
margin-top: 0px;
}
header nav ul li {
display: block;
float: left;
}
header nav ul li a {
text-decoration: none;
color: #333333;
font-size: 17px;
padding-top: 15px;
padding-bottom: 15px;
transition: all .2s linear;
-webkit-transition: all .2s linear;
-moz-transition: all .2s linear;
-o-transition: all .2s linear;
}
header nav ul li a.active,
header nav ul li a:hover {
color: #cc3333;
border-top: 1px dashed #cc3333;
border-bottom: 1px dashed #cc3333;
}
header li {
display: inline;
border-left: 1px dashed #cc3333;
padding: 10px 25px 10px 25px;
}
header li:first-child {
border: none;
}
#slogan {
margin-top: 5px;
color: #0c0c0c;
font-size: 16px;
display: block;
}
<header>
<div class="wrapper">
<div class="logo">
Name
<p id="slogan">Slogan should be right here</p>
</div>
<nav>
<ul>
<li>Category 1
</li>
<li>Category 2
</li>
<li>Category 3
</li>
<li>Category 4
</li>
</ul>
</nav>
</div>
</header>

Get your code:
html:
<header>
<div class="wrapper">
<div class="logo">
<h4>
Name
</h4>
<p>your slogan here</p>
</div>
<nav>
<ul>
<li>Category 1</li>
<li>Category 2</li>
<li>Category 3</li>
<li>Category 4</li>
</ul>
</nav>
</div>
</header>
<br><br>
<center><font color="#fff">My goal:</font><br><br>
<img src="http://i.imgur.com/aW7k0QI.png">
css:
body {
background: url(http://i.imgur.com/Asbdvgw.png);
font-family: 'Open Sans', sans-serif;
margin:0;
}
header {
width: 950px;
margin: auto;
position: relative;
background: #fff;
overflow: hidden;
}
.wrapper {
width: 950px;
margin: 0 auto;
}
header .logo{
border-left: 1px dashed #333333;
padding:5px 10px;
}
header .logo h4{
padding: 0px ;
text-decoration: none;
font-size: 30px;
color: #cc3333;
padding: 10px;
padding-bottom:0;
}
.logo h4{
margin:0;
padding:0;
}
.logo p{
color:rgba(0,0,0,0.7);
margin:0;
padding:0 10px;
}
header nav{
position:absolute;
right:0;
top:0;
margin: 0px 0px;
}
header nav ul{
margin: 0px;
}
header nav ul li{
display: block;
float: left;
margin: 0px;
}
header nav ul li a{
text-decoration: none;
color: #333333;
font-size: 17px;
padding-top: 15px;
padding-bottom: 15px;
transition: all .2s linear;
-webkit-transition: all .2s linear;
-moz-transition: all .2s linear;
-o-transition: all .2s linear;
}
header nav ul li a.active,
header nav ul li a:hover{
color: #cc3333;
border-top: 1px dashed #cc3333;
border-bottom: 1px dashed #cc3333;
}
header li {
display: inline;
border-left: 1px dashed #cc3333;
padding: 10px 25px 10px 25px;
}
header li:first-child {
border: none;
}

Here's an updated Fiddle.
Critical CSS:
header .slogan {
color: #000;
font-size: 20px;
display: block;
}
And HTML:
<div class="logo">
Name
<span class="slogan">Tagline here</span>
</div>

Related

How to get the sidebar to the right side of the screen

I'm new to css, so don't mind my skills, I copied this code from somebody else online.
What I want to do is, having the sidebar to be at the right and when you hover over it, the details pop out towards the left. I'd appreciate any help that I get.
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/4.7.0/css/font-awesome.min.css">
<div class="sidebar">
<nav>
<ul>
<li>
<i class="fa fa-facebook-f"></i><span>Facebook</span>
</li>
<li>
<i class="fa fa-instagram"></i><span>Instagram</span>
</li>
</ul>
</nav>
</div>
</link>
#import url('https://fonts.googleapis.com/css?family=Montserrat:600&display=swap');
.sidebar *{
background-color: #333;
margin: 0;
padding: 0;
list-style: none;
text-decoration: none;
box-sizing: border-box;
}
.sidebar {
display: inline;
font-family: 'Montserrat', sans-serif;
height: 100vh;
}
.sidebar nav{
position: absolute;
width: 70px;
margin-top: 125px;
transition: all 0.3s linear;
box-shadow: 2px 2px 8px 0px rgba(0,0,0,.4);
}
.sidebar nav li{
height: 60px;
position:relative;
}
.sidebar nav li a{
color: white;
display: block;
height: 100%;
width: 100%;
line-height: 60px;
padding-left:25%;
border-bottom: 1px solid rgba(0,0,0,.4);
transition: all .3s linear;
}
.sidebar nav li a i{
position:absolute;
top: 17px;
left: 20px;
font-size: 27px;
}
ul li a span{
display: none;
font-weight: bold;
letter-spacing: 1px;
text-transform: uppercase;
}
.sidebar a:hover {
z-index:1;
width: 300px;
border-bottom: 1px solid rgba(0,0,0,.5);
box-shadow: 0 0 1px 1px rgba(0,0,0,.3);
}
.sidebar ul li:hover a span{
padding-left: 30%;
display: block;
}
tried setting text-center, align-items properties didnt work
So The first thing I did was to add float:inline-end; to our .Sidebar{} and removed position:fixed; from our nav selector.
(my own first instinct was to use flexbox, but that's just me.)
This will make your sidebar float on the right side of the screen and your nav is just housed in it.
Then to change the direction of our animation, we change padding-left:20% of .Sidebar ul li:hover a span{} to padding-right:20% and add float:inline-end to .Sidebar nav li a{}.
And that's pretty much it I think.
I didn't have to touch our html code so here's what I ended up with in the stylesheet:
#import url('https://fonts.googleapis.com/css?family=Montserrat:600&display=swap');
body {
background-color: black;
}
.sidebar *{
margin: 0;
padding: 0;
list-style: none;
text-decoration: none;
box-sizing: border-box;
}
.sidebar {
display:inline;
float: inline-end;
font-family: 'Montserrat', sans-serif;
height: 100vh;
}
.sidebar nav{
width: 70px;
margin-top: 150px;
transition: all 0.3s linear;
box-shadow: 2px 2px 8px 0px rgba(0,0,0,.4);
}
.sidebar nav li{
height: 60px;
position:relative;
}
.sidebar nav li a{
color: white;
display: block;
float: inline-end;
height: 100%;
width: 100%;
line-height: 60px;
border-bottom: 1px solid rgba(0,0,0,.4);
transition: all .3s linear;
}
.sidebar nav li a i{
position:absolute;
float: inline-end;
top: 17px;
left: 20px;
font-size: 27px;
}
ul li a span{
display: none;
font-weight: bold;
letter-spacing: 1px;
text-transform: uppercase;
}
.sidebar a:hover {
z-index:1;
width: 300px;
border-bottom: 1px solid rgba(0,0,0,.5);
box-shadow: 0 0 1px 1px rgba(0,0,0,.3);
}
.sidebar ul li:hover a span{
padding-right:20%;
display: block;
} ```
After a few minutes of "calculated" guessing I found a solution. You say it needs to be a relative position but you don't say where it needs to go. So I just typed coordinates here, if you want to update these coordinates you will have to watch out because it is very sensitive (The coordinates aren't correct because I worked in a smaller window).
I hope this helped you (if so pls let me know), have a nice day :-)
#import url('https://fonts.googleapis.com/css?family=Montserrat:600&display=swap');
.sidebar *{
margin: 0;
padding: 0;
list-style: none;
text-decoration: none;
box-sizing: border-box;
}
.sidebar {
display: inline;
font-family: 'Montserrat', sans-serif;
height: 100vh;
}
.sidebar nav{
position: fixed;
/*You say it needs to be a relative position but you don't say where it needs to go:*/
top: 10px; left: 400px;
width: 70px;
margin-top: 150px;
transition: all 0.3s linear;
box-shadow: 2px 2px 8px 0px rgba(0,0,0,.4);
}
.sidebar nav li{
height: 60px;
position:relative;
}
.sidebar nav li a{
color: white;
display: block;
height: 100%;
width: 100%;
line-height: 60px;
padding-left:25%;
border-bottom: 1px solid rgba(0,0,0,.4);
transition: all .3s linear;
}
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/4.7.0/css/font-awesome.min.css">
<div class="sidebar">
<nav>
<ul>
<li>
<i class="fa fa-facebook-f"></i><span>Facebook</span>
</li>
<li>
<i class="fa fa-instagram"></i><span>Instagram</span>
</li>
</ul>
</nav>
</div>
</link>

CSS add margin to one element in menu

I'm wondering how to add a left-margin to the most right element in
the menu without changing HTML code.
MY CODE:
ul {
float: right;
list-style-type: none;
margin-top: 25px;
margin-right: 115px;
}
ul li {
display: inline-block;
}
ul li a {
text-decoration: none !important;
padding: 5px 20px;
border: 1px solid #000;
color: #000;
transition: 0.4s ease;
font-size: 20px !important;
}
ul li a.li-login {
text-decoration: none !important;
position: relative;
margin-left: 10px;
padding: 5px 10px;
color: #000;
transition: 0.4s ease;
font-size: 16px !important;
border: none;
}
ul li:nth-child(5){
margin-left: 20px;
}
<header>
<div class="main">
<ul>
<li>Home</li>
<li>EndlessBlow</li>
<li>My projects</li>
<li>About</li>
<li *ngIf="!isLogged"><input type="submit" class="a-login" value="Login" (click)="navigateToLogin()"></li>
<li *ngIf="isLogged"><input type="submit" class="a-login" value="Logout" (click)="doLogout()"></li>
</ul>
</div>
</header>
what the output I have:
but I need to add margin to have space like in the image below:
How can I achieve that with CSS?
You need:
width:100%;
text-align: center;
in your ul and
.a-login {
margin-left: 50px;
}
.a-login {
margin-left: 50px;
}
ul {
float: right;
list-style-type: none;
margin-top: 25px;
margin-right: 115px;
width:100%;
text-align: center;
}
ul li {
display: inline-block;
}
ul li a {
text-decoration: none !important;
padding: 5px 20px;
border: 1px solid #000;
color: #000;
transition: 0.4s ease;
font-size: 20px !important;
}
ul li a.li-login {
text-decoration: none !important;
position: relative;
margin-left: 10px;
padding: 5px 10px;
color: #000;
transition: 0.4s ease;
font-size: 16px !important;
border: none;
}
<div class="main">
<ul>
<li>Home</li>
<li>EndlessBlow</li>
<li>My projects</li>
<li>About</li>
<li *ngIf="!isLogged"><input type="submit" class="a-login" value="Login" (click)="navigateToLogin()"></li>
<li *ngIf="isLogged"><input type="submit" class="a-login" value="Logout" (click)="doLogout()"></li>
</ul>
</div>
you've many options but my choice would be number 1:
1
ul li:last-child {
margin-left: 30px;
}
2
ul li:nth-last-child(2) {
margin-right: 30px;
}
3
ul li a[href="/about"] {
margin-right: 30px;
}
4
ul li:nth-child(4) {
margin-right: 30px;
}
5
ul li:nth-child(5) {
margin-left: 30px;
}
You can use the pseudo-class called nth-child(n), with this class you can select a child element based on the number n, in the code below you select the five li element which is a child and add a margin to it, now you can add styles only to the 5 li element.
ul {
float: right;
list-style-type: none;
margin-top: 25px;
margin-right: 115px;
}
ul li {
display: inline-block;
}
ul li a {
text-decoration: none !important;
padding: 5px 20px;
border: 1px solid #000;
color: #000;
transition: 0.4s ease;
font-size: 20px !important;
}
ul li a.li-login {
text-decoration: none !important;
position: relative;
margin-left: 10px;
padding: 5px 10px;
color: #000;
transition: 0.4s ease;
font-size: 16px !important;
border: none;
}
ul li:nth-child(5){
margin-left: 20px;
}
<header>
<div class="main">
<ul>
<li>Home</li>
<li>EndlessBlow</li>
<li>My projects</li>
<li>About</li>
<li *ngIf="!isLogged"><input type="submit" class="a-login" value="Login" (click)="navigateToLogin()"></li>
<li *ngIf="isLogged"><input type="submit" class="a-login" value="Logout" (click)="doLogout()"></li>
</ul>
</div>
</header>

Drop Down Menu is Overlapping my Nav Bar

I'm building a site for a client and I'm having trouble getting the drop down menu to appear clear below the navbar - instead it is overlapping the navbar, and if I increase the top margin of the drop down menu to push it below the navbar there is a gap between the drop down and the parent list item where the hover property to make it appear does not take affect.
I've created a fiddle of the navbar here - http://jsfiddle.net/s4dpby4v/1/
And you can view the live version here - http://japesfawcett.com/ps/index.html
HTML:
<div class="header">
<div class="logo">
<h1>PAM SHAW INTERIORS</h1>
</div>
<nav>
<ul>
<li>ABOUT</li>
<li class="has-drop">
WORK +
<ul class="drop-down">
<li style="padding-bottom: 0;">COMMERCIAL</li>
<li style="padding-right: 80px; padding-bottom: 0;">RESIDENTIAL</li>
</ul>
</li>
<li>CONTACT</li>
</ul>
</nav>
</div>
CSS:
.header {
width: 100%;
background-color: #fff;
margin: 0 auto;
height: 75px;
z-index: 9999;
}
.logo h1 {
float: left;
font-size: 20px;
letter-spacing: 4px;
width: 25%;
padding-top: 10px;
margin-top: 18px;
margin-left: 75px;
font-weight: 300;
}
.logo a {
text-decoration: none;
color: #000;
}
nav {
font-family: 'Lato', sans-serif;
width: 60%;
font-size: 14px;
font-weight: 300;
text-align: right;
letter-spacing: 4px;
float: right;
margin-top: 19px;
margin-right: 75px;
}
nav ul {
float: right;
list-style: none;
padding-top: -5px;
}
nav li {
padding-left: 15px;
padding-right: 10px;
padding-bottom: 15px;
display: inline-block;
}
nav ul li ul.drop-down {
width: 100%;
background: #fff;
display: none;
position: absolute;
z-index: 999;
padding: 5px 0 5px 0;
margin: 15px 0 0 0;
left: 0;
line-height: 2.5;
clear: both;
border-top: 1px solid #F1F1F1;
}
nav li:hover ul.drop-down {
display: block;
}
nav ul li ul.dropdown li {
display: block;
padding: 0;
margin: 0;
}
nav li a {
text-decoration: none;
color: #000;
display: inline-block;
}
nav li a:hover {
text-decoration: none;
color: #CCC;
-webkit-transition: all 800ms ease;
-moz-transition: all 800ms ease;
-ms-transition: all 800ms ease;
-o-transition: all 800ms ease;
transition: all 800ms ease;
}
Any guidance or help would be greatly appreciated!
.has-drop {position: relative;}
nav ul li ul.drop-down {width: auto;}
nav li li {width: 100%; text-align: center; box-sizing: border-box;}
Will clean up you drop down, you just need to remove the inline styles that you have on here to fix up the list styles.:
<li style="padding-bottom: 0;">COMMERCIAL</li>
<li style="padding-right: 80px; padding-bottom: 0;">RESIDENTIAL</li>
Here is my fiddle: http://jsfiddle.net/s4dpby4v/6/
You can check with this css
.has-drop {
padding-bottom: 30px;
}
nav ul li ul.drop-down
{
margin: 27px 0 0;
}

Navigation list item taking excess space when hovering

When I hover on "Newsletter" it takes large space, I tried to adjust margin but nothing happened, and I also tried margin-left and margin-right but the problem is the same. Below is the code:
hr {
margin: 0px;
}
body {
background: url(../images/bg.jpg);
background-repeat: no-repeat;
background-size: cover;
word-wrap: break-word;
}
h1 {
font-family: "Sacramento";
color: #F0FFF0;
}
.title >h1 {
color: #222;
transition: color 2s;
}
.title:hover >h1 {
color: #6565f0;
}
.title {
line-height: 40px;
margin-top: 0px;
margin-bottom: -22px;
font-size: 19px;
transition: font-size 0.4s;
}
.title:hover {
font-size: 22px;
}
.nav ul {
background-color: transperent;
list-style: none;
padding: 0;
margin: 0;
text-align: center;
}
.nav li {
font-family: 'Oswald', sans-serif;
font-size: 1.2em;
line-height: 40px;
margin-top: 10px;
height: 40px;
border-bottom: 1px solid #888;
transition: font-size 0.4s;
}
.nav li:hover {
font-size: 1.6em;
}
.nav a {
text-decoration: none;
color: #222;
display: block;
transition: .3s background-color;
}
.nav a:hover {
background-color: #005f5f;
}
.nav a.active {
background-color: #fff;
color: #444;
cursor: default;
}
#media screen and (min-width: 600px) {
.nav li {
width: 120px;
border-bottom: none;
height: 50px;
line-height: 50px;
font-size: 1.4em;
}
/* Option 1 - Display Inline*/
.nav li {
display: inline-block;
margin-right: 10px;
margin-left: 10px;
}
}
<font align=center>
<div class="title">
<h1>Welcome</h1>
</div>
</font>
<hr />
<div class="nav">
<ul>
<li class="home">Home
</li>
<li class="tutorials">Tutorials
</li>
<li class="about">About
</li>
<li class="news"><a href="fb.com" target=_blank>Newsletter</a>
</li>
<li class="contact">Contact
</li>
</ul>
</div>
<hr style="margin-top:5px;" />
Update width of li to width:130px;
.nav li {
width:130px;
}

Border-bottom needs to move up on hover

I want to have a border (looks like underline) that moves up on hover.
So if this is a link:
LINK
Then if I hover on it
LINK
""""
Example from the website:
http://matthias-schoenaerts.com/
(navigation bar)
I want it as simple as possible.
This is what I came up with:
http://jsfiddle.net/Lxxqz3pL/
HTML:
<ul id="nav">
<li>About Us</li>
<li>Our Products</li>
<li>FAQs</li>
<li>Contact</li>
<li>Login</li>
</ul>
CSS:
/* Begin Navigation Bar Styling */
#nav {
width: 100%;
float: center;
margin: 0 0 3em 0;
left: 0;
padding: 0;
list-style: none;
background-color: #333333;
border-bottom: 1px solid #ccc;
border-top: 1px solid #ccc;
position: absolute;
}
#nav li {
float: left;
}
#nav li a {
display: block;
padding: 8px 15px;
text-decoration: none;
font-weight: bold;
color: #a3a3a3;
}
#nav li a:hover {
transition: border .5s ease-in;
background-color: #fff;
border-bottom: 3px solid red;
}
/* End navigation bar styling. */
Here is updated CSS, does it what you trying to get?
/* Begin Navigation Bar Styling */
#nav {
width: 100%;
float: center;
margin: 0 0 3em 0;
left: 0;
padding: 0;
list-style: none;
background-color: #333333;
border-bottom: 1px solid #ccc;
border-top: 1px solid #ccc;
position: absolute;
overflow: hidden;
}
#nav li {
float: left;
}
#nav li a {
display: block;
padding: 8px 15px;
text-decoration: none;
font-weight: bold;
color: #a3a3a3;
}
#nav li a:after{
display:block;
width:100%;
height:0px;
content:" ";
border:1px solid red;
position: relative;
top:10px;
}
#nav li a:hover:after{
transition: 0.5s ease-in;
transform: translate(0px, -10px);
}
/* End navigation bar styling. */
I've modified your code in areas to get the desired effect
DEMO http://jsfiddle.net/Lxxqz3pL/3/
#nav li a {
display: block;
padding: 8px 15px;
text-decoration: none;
font-weight: bold;
color: #a3a3a3;
padding: 22px 0 35px;
color: #a3a3a3;
border-bottom: 3px solid #6a901b;
transition: all 0.5s ease;
}
#nav li a:hover {
transition: all 0.5s ease;
color: #fff;
padding-bottom: 5px;
}
How about something like this? FIDDLE.
Just keep the background fixed, add a border at the bottom, and make the height of the anchor smaller.
Relevant CSS
#nav li {
float: left;
height: 40px;
}
#nav li a {
display: block;
padding: 8px 15px;
text-decoration: none;
font-weight: bold;
color: #a3a3a3;
height: 20px;
transition: height 0.5s;
}
#nav li a:hover {
height: 10px;
border-bottom: 3px solid red;
}
It looks like the example site uses flexNav, a jQuery plugin.
http://jasonweaver.name/lab/flexiblenavigation/
Here's a quick-fix solution. I added a transition to <li> padding to compensate for the added border.
http://jsfiddle.net/Lxxqz3pL/1/