The words or text below the logo in the navbar are not moving to the right of the logo (for reference link to the page -> http://127.0.0.1:5500/index.html).
Additionally the logo is not shifting to its left – it’s happening in basically all the navbar codes. I’m trying to do this using CSS bootstrap. Any explanation would be very helpful since I have recently started learning bootstrap CSS.
JavaScript
x
41
41
1
body {
2
font-size: 16px;
3
color: #fff;
4
background-color: #F5EEE0;
5
font-family: 'Oxygen', sans-serif;
6
}
7
8
/** HEADER **/
9
#header-nav {
10
background-color: #AE7F60;
11
border-radius: 0;
12
border: 0;
13
}
14
15
#logo-img {
16
background: url('../images/coffee-shop-logo_large.png') no-repeat;
17
width: 150px;
18
height: 150px;
19
margin: 10px 15px 10px 0;
20
}
21
22
.navbar-brand {
23
padding-top: 25px;
24
}
25
26
.navbar-brand h1{ /*Resturant name */
27
object-position: right;
28
font-family: 'Lora', sans-serif;
29
color: #B35840;
30
font-size: 1.5cm;
31
text-transform: uppercase;
32
font-weight: bold;
33
text-shadow: 1px 1px 1px #222;
34
margin-top: 0;
35
margin-bottom: 0;
36
line-height: .75;
37
}
38
.navbar-brand a:hover, .navbar-brand a:focus{
39
text-decoration: none;
40
}
41
JavaScript
1
38
38
1
<!DOCTYPE html>
2
<html lang="en">
3
<head>
4
<meta charset="utf-8">
5
<meta http-equiv="X-UA-Compatible" content="IE=edge">
6
<meta name="viewport" content="width=device-width, initial-scale=1">
7
<title>coffee cafe</title>
8
<link rel="stylesheet" href="css/bootstrap.min.css">
9
<link rel="stylesheet" href="css/styles.css">
10
<link href='https://fonts.googleapis.com/css?family=Oxygen:400,300,700' rel='stylesheet' type='text/css'>
11
<link href='https://fonts.googleapis.com/css?family=Lora' rel='stylesheet' type='text/css'>
12
</head>
13
<body>
14
<header>
15
<nav id="header-nav" class="navbar navbar-default">
16
<div class="container">
17
<div class="navbar-header">
18
<a href="index.html" class="pull-left visble-md visible-lg ">
19
<div id="logo-img" alt="Logo image"></div>
20
</a>
21
22
<div class="navar-brand">
23
<a href="index.html"><h1>Coffee Place</h1></a>
24
</div>
25
26
27
</div>
28
</nav>
29
</header>
30
31
32
<!-- jQuery (Bootstrap JS plugins depend on it) -->
33
<script src="js/jquery-3.6.0.min.js"></script>
34
<script src="js/bootstrap.min.js"></script>
35
<script src="js/script.js"></script>
36
</body>
37
</html>
38
Advertisement
Answer
You need to add .d-flex
in div.navbar-header
.
also add a little margin in you h1
to make it vertically align with the logo or you can also you vertical-align
property.
I’ve also closed the unclosed container div.
JavaScript
1
43
43
1
body {
2
font-size: 16px;
3
color: #fff;
4
background-color: #F5EEE0;
5
font-family: 'Oxygen', sans-serif;
6
}
7
8
/** HEADER **/
9
#header-nav {
10
background-color: #AE7F60;
11
border-radius: 0;
12
border: 0;
13
}
14
15
#logo-img {
16
background: url('https://www.svgrepo.com/show/15418/coffee-cup.svg') no-repeat;
17
width: 50px;
18
height: 50px;
19
margin: 10px 15px 10px 0;
20
}
21
22
.navbar-brand {
23
padding-top: 25px;
24
}
25
26
.navbar-brand h1 {
27
/*Resturant name */
28
object-position: right;
29
font-family: 'Lora', sans-serif;
30
color: #B35840;
31
font-size: 1.5cm;
32
text-transform: uppercase;
33
font-weight: bold;
34
text-shadow: 1px 1px 1px #222;
35
margin-top: 0;
36
margin-bottom: 0;
37
line-height: .75;
38
}
39
40
.navbar-brand a:hover,
41
.navbar-brand a:focus {
42
text-decoration: none;
43
}
JavaScript
1
26
26
1
<script src="https://cdn.jsdelivr.net/npm/bootstrap@5.1.3/dist/js/bootstrap.bundle.min.js"></script>
2
<link href="https://cdn.jsdelivr.net/npm/bootstrap@5.1.3/dist/css/bootstrap.min.css" rel="stylesheet"/>
3
<script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/3.3.1/jquery.min.js"></script>
4
<link href='https://fonts.googleapis.com/css?family=Oxygen:400,300,700' rel='stylesheet' type='text/css'>
5
<link href='https://fonts.googleapis.com/css?family=Lora' rel='stylesheet' type='text/css'>
6
7
8
<header>
9
<nav id="header-nav" class="navbar navbar-default">
10
<div class="container">
11
12
<div class="d-flex navbar-header">
13
14
<a href="index.html" class="pull-left visble-md visible-lg">
15
<div id="logo-img" alt="Logo image"></div>
16
</a>
17
18
<div class="navar-brand">
19
<a href="index.html"><h1 class="mt-3">Coffee Place</h1></a>
20
</div>
21
22
</div>
23
24
</div>
25
</nav>
26
</header>