看一下下拉菜单。你有没有发现它看起来很奇怪,而且不直!我该怎么解决这个问题?
我已经尝试了float,margin和其他一些技巧,似乎没有什么可以解决下拉菜单的问题。我被告知JavaScript。但是,我不想走那条路。我应该怎么做来解决这些问题?
body{font-family: 'Open Sans', sans-serif;font-weight: 300;
background-image:linear-gradient(to bottom right, #00f490, #00bbc9)}
h1{font-family: 'Abril Fatface', cursive; font-size:4.3 rem ;}
.jumbotron{background-color:rgba(0250, 235, 215, 0)}
.drop-shadow{text-shadow:0px 2px 3px rgba(0, 0, 0, 0.153);}
.lead{color:white;
font: size 2.2rem;}
.btn-outline-light{border-color:white ;}
btn-outline-light:hover {background-color:rgba(255, 255, 255, 0.057) ;}
<!doctype html>
<html lang="en">
<head>
<!-- Required meta tags -->
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1">
<!-- Bootstrap CSS -->
<link href="https://cdn.jsdelivr.net/npm/bootstrap@5.1.3/dist/css/bootstrap.min.css" rel="stylesheet" integrity="sha384-1BmE4kWBq78iYhFldvKuhfTAU6auU8tT94WrHftjDbrCEXSU1oBoqyl2QvZ6jIW3" crossorigin="anonymous">
<link rel="preconnect" href="https://fonts.googleapis.com">
<link rel="preconnect" href="https://fonts.gstatic.com" crossorigin>
<link rel="preconnect" href="https://fonts.googleapis.com">
<link rel="preconnect" href="https://fonts.gstatic.com" crossorigin>
<link href="https://fonts.googleapis.com/css2?family=Abril+Fatface&family=Open+Sans:wght@300&display=swap" rel="stylesheet">
<link rel ="stylesheet" href="stle.css">
<title>Hello, world!</title>
</head>
<body>
<!--Navigation-->
<div class="container">
<nav class="navbar navbar-expand-lg navbar-dark sticky-top float-right">
<div class="container-fluid">
<nav class="navbar">
<div class="container">
<a class="navbar-brand" href="#">
<img src="/images/logo-dans-meat-yogurt.svg" alt="Dan's yogurt Company " width="150" height="ms-auto">
</a>
</div>
</nav>
<button class="navbar-toggler" type="button" data-bs-toggle="collapse" data-bs-target="#navbarSupportedContent" aria-controls="navbarSupportedContent" aria-expanded="false" aria-label="Toggle navigation">
<span class="navbar-toggler-icon"></span>
</button>
<div class="collapse navbar-collapse justify-content" id="navbarSupportedContent">
<ul class="navbar-nav ms-auto mb-2 mb-lg-0 text-dark">
<li class="nav-item btn btn-outline-light ">
<a class="nav-link active" aria-current="page" href="#">Home</a>
<!--button Drop down-->
</li>
<li class="nav-item dropdown btn btn-outline-light mx-4" style = "width:120px;">
<a class="nav-link dropdown-toggle text-" href="#" id="navbarDropdown" role="button" data-bs-toggle="dropdown" aria-expanded="false">
Flavors
</a>
<ul class="dropdown-menu float-start
" aria-labelledby="navbarDropdown">
<li><a class="dropdown-item" href="#">Ham</a></li>
<li><a class="dropdown-item" href="#">Beef</a></li>
<li><a class="dropdown-item" href="#"> Chicken
</a></li>
<li><a class="dropdown-item" href="#"> Fish
</a></li>
</ul>
<!--Button Normal -->
<li class="nav-item btn btn-outline-light text-white"style = "width:120px";>
<a class="nav-link" href="#">Link</a>
</li>
</ul>
</div>
</div>
</nav>
<!--Jumbotrun-->
<div class="jumbotron">
<div class="row">
<div class="col-12 col-md-7 text-center text-md-left">
<h1 class="display-3 text-white drop-shadow">Thick & Creamy</h1>
<p class="lead">With real meat chunks !</p>
<a class="btn btn-outline-light btn-lg mt-4 px-5 py-3 mb-5" href="#" role="button">Pricing</a></p></div>
<div class="col-12 mt-5 col-md-5 mb-md-0"><img src ="/images/hero1.png" alt="Dan's Meat Yougurts" class="float-right img-fluid">
</div>
</div>
</div>
<!--Carosel-->
<div id="carouselExampleDark" class="carousel carousel-dark slide" data-bs-ride="carousel">
<div class="carousel-indicators">
<button type="button" data-bs-target="#carouselExampleDark" data-bs-slide-to="0" class="active" aria-current="true" aria-label="Slide 1"></button>
<button type="button" data-bs-target="#carouselExampleDark" data-bs-slide-to="1" aria-label="Slide 2"></button>
<button type="button" data-bs-target="#carouselExampleDark" data-bs-slide-to="2" aria-label="Slide 3"></button>
</div>
<div class="carousel-inner">
<div class="carousel-item active" data-bs-interval="10000">
<img src="/images/yogurt-1.png" class="d-block w-100" alt="...">
<div class="carousel-caption d-none d-md-block">
<h5>First slide label</h5>
<p>Some representative placeholder content for the first slide.</p>
</div>
</div>
<div class="carousel-item" data-bs-interval="2000">
<img src="/images/yogurt-2.png" class="d-block w-100" alt="...">
<div class="carousel-caption d-none d-md-block">
<h5>Second slide label</h5>
<p>Some representative placeholder content for the second slide.</p>
</div>
</div>
<div class="carousel-item">
<img src="/images/yogurt-3.png" class="d-block w-100" alt="...">
<div class="carousel-caption d-none d-md-block">
<h5>Third slide label</h5>
<p>Some representative placeholder content for the third slide.</p>
</div>
</div>
</div>
<button class="carousel-control-prev" type="button" data-bs-target="#carouselExampleDark" data-bs-slide="prev">
<span class="carousel-control-prev-icon" aria-hidden="true"></span>
<span class="visually-hidden">Previous</span>
</button>
<button class="carousel-control-next" type="button" data-bs-target="#carouselExampleDark" data-bs-slide="next">
<span class="carousel-control-next-icon" aria-hidden="true"></span>
<span class="visually-hidden">Next</span>
</button>
</div>
<!--Cards-->
<div class="card" style="width: 18rem;">
<img class="card-img-top" src="/images/product1.png" alt="Card image cap">
<div class="card-body">
<p class="card-text">Some quick example text to build on the card title and make up the bulk of the card's content.</p>
</div>
</div><div class="card" style="width: 18rem;">
<img class="card-img-top" src="images/product2.png" alt="Card image cap">
<div class="card-body">
<p class="card-text">Some quick example text to build on the card title and make up the bulk of the card's content.</p>
</div>
</div><div class="card" style="width: 18rem;">
<img class="card-img-top" src="/images/product3.png" alt="Card image cap">
<div class="card-body">
<p class="card-text">Some quick example text to build on the card title and make up the bulk of the card's content.</p>
</div>
</div>
</div>
<!-- Optional JavaScript; choose one of the two! -->
<!-- Option 1: Bootstrap Bundle with Popper -->
<script src="https://cdn.jsdelivr.net/npm/bootstrap@5.1.3/dist/js/bootstrap.bundle.min.js" integrity="sha384-ka7Sk0Gln4gmtz2MlQnikT1wXgYsOg+OMhuP+IlRH9sENBO0LRn5q+8nbTov4+1p" crossorigin="anonymous"></script>
</body>
</html>
1条答案
按热度按时间2hh7jdfx1#
删除
mx-4
,并将其替换为m-auto
(用于margin: auto;
)。