i am trying to make an unordered list in the navbar and make anchors inline but the style doesn't apply. the below style of stylish navbar not working . but it applies when i try to change background color
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>portfolio</title>
<link rel="stylesheet" href="style.css">
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/6.1.1/css/all.min.css" integrity="sha512-KfkfwYDsLkIlwQp6LFnl8zNdLGxu9YAA1QvwINks4PhcElQSvqcyVLLD9aMhXd13uQjoXtEKNosOWaZqXgel0g==" crossorigin="anonymous" referrerpolicy="no-referrer" />
</head>
<body>
<div >
<nav >
<h1 >portfolio</h1>
<ul>
<li ><a href="#"></a>home </li>
<li ><a href="#"></a> about</li>
<li ><a href="#"></a>services </li>
<li ><a href="#"></a> skills</li>
<li ><a href="#"></a>contact </li>
</ul>
</nav>
</div>
</body>
</html>
css style
*{
padding: 0;
margin: 0;
box-sizing: border-box;
}
.logo{
padding: 5px;
}
.header{
height: 100vh;
width: 100%;
background-image:url(./img/code.jpg) ;
background-repeat: no-repeat;
background-size: cover;
background-position: center;
}
.stylishnavbar{
display: flex;
align-items: center;
}
CodePudding user response:
Flex only applies to the immediate children. Right now, it's just applying to the h1 and ul.
Add
.stylishnavbar > ul { display: flex; }
To apply flex to your list.
CodePudding user response:
I hope this code will solve your problem...
*{
padding: 0;
margin: 0;
box-sizing: border-box;
}
.logo {
padding: 5px;
}
.header {
height: 100vh;
width: 100%;
background-repeat: no-repeat;
background-size: cover;
background-position: center;
}
.stylishnavbar {
display: flex;
align-items: center;
}
nav.stylishnavbar ul {
display: flex;
list-style: none;
}
nav.stylishnavbar ul li{
margin-right: 30px
}
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>portfolio</title>
<link rel="stylesheet" href="style.css">
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/6.1.1/css/all.min.css"
integrity="sha512-KfkfwYDsLkIlwQp6LFnl8zNdLGxu9YAA1QvwINks4PhcElQSvqcyVLLD9aMhXd13uQjoXtEKNosOWaZqXgel0g=="
crossorigin="anonymous" referrerpolicy="no-referrer" />
</head>
<body>
<div >
<nav >
<h1 >portfolio</h1>
<ul>
<li><a href="#"></a>home </li>
<li><a href="#"></a> about</li>
<li><a href="#"></a>services </li>
<li><a href="#"></a> skills</li>
<li><a href="#"></a>contact </li>
</ul>
</nav>
</div>
</body>
</html>