调整图像大小后,图像和导航栏中的链接将向下和向右移动

时间:2019-02-26 00:32:48

标签: html css

我正在尝试将图像和文本与导航栏左侧的图像重新对齐并居中放置,但无法弄清楚。

<button type="submit" class="btn btn-info" disabled>Next</button>
body {
  background-color: #FFF;
  margin: auto;
}

header {
  background-color: #466995;
  border-bottom: 1px solid #466995;
  position: fixed;
  width: 100%;
  z-index: 10;
}

ul {
  margin: 30px auto;
  padding: 0px 20px;
  text-align: center;
  height: 25px;
}

li {
  color: #FFF;
  font-family: 'Oswald', sans-serif;
  font-size: 16px;
  font-weight: 300;
  text-transform: uppercase;
  display: inline-block;
  width: 80px;
  border-radius: 15px;
  border: 2px solid transparent;
  position: relative;
  bottom: 10px;
  padding: 10px;
}

li:hover {
  color: #DBE9EE;
}

.ninja {
right: 380px;
position: relative;
margin: 0px;
}

h1 {
  color: #466995;
  font-family: 'Oswald', sans-serif;
  font-size: 32px;
  font-weight: 300;
  text-transform: uppercase;
}

h2 {
  color: #333;
  font-family: 'Varela Round', sans-serif;
  font-size: 26px;
  font-weight: 100;
  margin: 0 auto 20px auto;
}

h3 {
  color: #466995;
  font-family: 'Oswald', sans-serif;
  font-size: 18px;
  text-align: center;
  font-weight: 700;
  text-transform: uppercase;
  padding: 30px;
}

h4 {
  color: #466995;
  font-family: 'Oswald', sans-serif;
  font-size: 18px;
  font-weight: 300;
  letter-spacing: 2px;
  text-align: center;
  text-transform: uppercase
}

p {
  color: #333;
  font-family: 'Varela Round', sans-serif;
  font-size: 18px;
}

footer {
  background-color: #DBE9EE;
  text-align: center;
  height: 100px;
  margin-top: 50px;
}

.welcome {
  background-color: #DBE9EE;
  box-sizing: border-box;
  padding: 40px;
  text-align: center;
  width: 100%;
  position: relative;
  top: 50px;
}

a {
text-decoration: none;
}

.socials {
display: inline-block;
margin: 20px;
}

.steven {
display: inline-block;
}

.rideimages {
display: inline-block;
}


.ulride {
text-align: center;
margin-left: 105px;
margin-right: 105px;
margin-top: 100px;
margin-bottom: 100px;
}

1 个答案:

答案 0 :(得分:1)

只需在CSS中使用flex。您没有指定必须放置菜单的位置,因此我将其放置在右边。是你想要的吗? CodePen

body {
  background-color: #fff;
  margin: auto;
}

.wrapper {
  width: 1200px;
  margin: 0 auto;
}

@media(max-width: 1200px){
.wrapper {
  width: auto;
  }
}

header {
  background-color: #466995;
  border-bottom: 1px solid #466995;
  position: fixed;
  width: 100%;
  z-index: 10;
}

header ul {
    margin: 10px auto;
    padding: 0px 20px;
    text-align: center;
}

header ul .steven, header ul .steven div {
  display: flex;
  align-items: center;
}

header ul .steven {
  justify-content: space-between;
}

li {
  color: #fff;
  font-family: "Oswald", sans-serif;
  font-size: 16px;
  font-weight: 300;
  text-transform: uppercase;
  display: inline-block;
  width: 80px;
  border-radius: 15px;
  border: 2px solid transparent;
  position: relative;
  padding: 10px;
}

li:hover {
  color: #dbe9ee;
}

.ninja {
  position: relative;
  margin: 0px;
}

h1 {
  color: #466995;
  font-family: "Oswald", sans-serif;
  font-size: 32px;
  font-weight: 300;
  text-transform: uppercase;
}

h2 {
  color: #333;
  font-family: "Varela Round", sans-serif;
  font-size: 26px;
  font-weight: 100;
  margin: 0 auto 20px auto;
}

h3 {
  color: #466995;
  font-family: "Oswald", sans-serif;
  font-size: 18px;
  text-align: center;
  font-weight: 700;
  text-transform: uppercase;
  padding: 30px;
}

h4 {
  color: #466995;
  font-family: "Oswald", sans-serif;
  font-size: 18px;
  font-weight: 300;
  letter-spacing: 2px;
  text-align: center;
  text-transform: uppercase;
}

p {
  color: #333;
  font-family: "Varela Round", sans-serif;
  font-size: 18px;
}

footer {
  background-color: #dbe9ee;
  text-align: center;
  height: 100px;
  margin-top: 50px;
}

.welcome {
  background-color: #dbe9ee;
  box-sizing: border-box;
  padding: 40px;
  text-align: center;
  width: 100%;
  position: relative;
  top: 50px;
}

a {
  text-decoration: none;
}

.socials {
  display: inline-block;
  margin: 20px;
}

.steven {
  display: inline-block;
}

.rideimages {
  display: inline-block;
}

.ulride {
  text-align: center;
  margin-left: 105px;
  margin-right: 105px;
  margin-top: 100px;
  margin-bottom: 100px;
}
<!DOCTYPE html>
<html>

<head>
  <title>Please Participate in Our Survey!</title>
  <link href="https://fonts.googleapis.com/css?family=Oswald:300,700|Varela+Round" rel="stylesheet">
  <link rel="stylesheet" type="text/css" href="style.css">
</head>

<body>
  <header>
    <div class="wrapper">
      <ul>
      <div class="steven">
        <a class="ninja" href="https://cheese.com/" target="_blank"><img src="http://www.the-green-pantry.com/image/760/390/_data/uploads/huelsen.gif" width="65px" height="65px"></a>
        <div>
          <a href="#home">
          <li>Home</li>
        </a>
        <a href="#rides">
          <li>Rides</li>
        </a>
        <a href="#pricing">
          <li>Pricing</li>
        </a>
        <a href="#open hours">
          <li>Open Hours</li>
        </a>
        </div>
      </div>
    </ul>
    </div>
  </header>
  <div class="welcome">
    <h1>Welcome to Legume land, where your dreams become reality!</h1>
    <p>Join us today!</p>
  </div>
  <div class="rideimages">
    <ul class="ulride">
      <img class="1" src="Images/ride1.jpg" width="250px" height="250px">
      <img class="2" src="Images/ride2.jpg" width="250px" height="250px">
      <img class="3" src="Images/ride3.jpg" width="250px" height="250px">
      <img class="4" src="Images/ride4.jpg" width="250px" height="250px">
    </ul>
  </div>

  <footer>
    <div class="socials">
      <a href="https://www.youtube.com/watch?v=dQw4w9WgXcQ" target="_blank"><img src="Images/Youtube.svg" width="60" height="60"></a>
      <a href="https://www.youtube.com/watch?v=dQw4w9WgXcQ" target="_blank"><img src="Images/Instagram.svg" width="60" height="60"></a>
      <a href="https://www.youtube.com/watch?v=dQw4w9WgXcQ" target="_blank"><img src="Images/Facebook.svg" width="60" height="60"></a>
      <a href="https://www.youtube.com/watch?v=dQw4w9WgXcQ" target="_blank"><img src="Images/Twitter.svg" width="60" height="60"></a>
    </div>
  </footer>
</body>

</html>