为什么我的图像不会向上移动?

时间:2017-02-14 23:20:30

标签: html css image css3

我无法让这个形象向我的生活迈进。我已经尝试了一切,但它不起作用。我希望我的图片与PV图片对齐,水平对齐。

我希望我的HP图片垂直向上移动,以便水平对齐我的PV图片。

这是我的index.html文件:

<!DOCTYPE html>
<html>

<head>
 <title>Website</title>
 <meta charset="utf-8">
 <meta name="viewport" content="width=device-width, initial-scale=1">
 <link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/4.6.3/css/font-awesome.min.css">
 <link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap.min.css">

 <link rel="stylesheet" href="index.css">
 <script src="https://ajax.googleapis.com/ajax/libs/jquery/3.1.1/jquery.min.js"></script>
 <script src="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/js/bootstrap.min.js"></script>
 <script src="https://unpkg.com/react@15/dist/react.js"></script>
 <script src="https://unpkg.com/react-dom@15/dist/react-dom.js"></script>
 <script src="https://cdnjs.cloudflare.com/ajax/libs/babel-core/5.6.16/browser.js"></script>
</head>

<header>
  <nav>
    <ul>
      <button type="button" class="btn btn-primary">Portfolio</button>
      <button type="button" class="btn btn-primary">About</button>
      <button type="button" class="btn btn-primary">Contact</button>
    </ul>
  </nav>
  <img src="./pictures/skyline.jpg" class="mainPic"></img></br>
</header>

<body class="content">
  <nav>
    <h2><u>Portfolio</u></h2>

    <li>
      <!-- PV -->
      <div class="container">


        <img class="pvPic" src="./pictures/portfolioPic1.png"></img>


        <div class="middlePv">
          <div class="pvText">Menu for catering company.</div>
        </div>

      </div>

      <!-- WFAFA -->
      <div class="container">
        <img src="./pictures/WFAFA.png" class="WFAFAPic img-rounded"></img>
        <div class="middleWFAFA">
          <div class="WFAFAText">Worlds first automated financial advisor.</div>
        </div>
      </div>

      <!-- Hunts Points Shipyard LLC -->

      <div class="container2">
        <img src="./pictures/HP.png" class="HPPic img-rounded"></img>
        <div class="middleHP">
          <div class="HPText">Hunts Point Seaport and Shipyard LLC company website.</div>
        </div>
      </div>

    </li>

  </nav>
</body>


</html>

这是我的index.css文件:

html {
  text-align: center;
}
/* PV */
.container {
  position: relative;
}

.pvPic {
  display: block;
  max-width: 30%;
  height: auto;
  opacity: 1;
  transition: .5s ease;
  backface-visibility: hidden;
}

.middlePv {
  transition: .5s ease;
  opacity: 0;
  position: absolute;
  top: 50%;
  left: 16%;
  transform: translate(-50%, -50%);
  -ms-transform: translate(-50%, -50%)
}

.container:hover .pvPic {
  opacity: 0.3;
}

.container:hover .middlePv {
  opacity: 1;
}

.pvText {
  background-color: #4CAF50;
  color: white;
  font-size: 16px;
  padding: 16px 32px;
}

/* WFAFA */

.container {
  position: relative;
}

.WFAFAPic {
  display: block;
  max-width: 30%;
  height: auto;
  opacity: 1;
  transition: .5s ease;
  backface-visibility: hidden;
}

.middleWFAFA {
  transition: .5s ease;
  opacity: 0;
  position: absolute;
  top: 50%;
  left: 16%;
  transform: translate(-50%, -50%);
  -ms-transform: translate(-50%, -50%)
}

.container:hover .WFAFAPic {
  opacity: 0.3;
}

.container:hover .middleWFAFA {
  opacity: 1;
}

.WFAFAText {
  background-color: #4CAF50;
  color: white;
  font-size: 16px;
  padding: 16px 32px;
}

/* HP Shipyard */

.container {
  position: relative;
}

.HPPic {
  display: block;
  max-width: 30%;
  height: auto;
  opacity: 1;
  transition: .5s ease;
  backface-visibility: hidden;
  float: right;
  display: inline-block;
  vertical-align: top;
}

.middleHP {
  transition: .5s ease;
  opacity: 0;
  position: absolute;
  top: 49%;
  left: 87%;
  transform: translate(-50%, -50%);
  -ms-transform: translate(-50%, -50%)
}

.container:hover .HPPic {
  opacity: 0.3;
}

.container:hover .middleHP {
  opacity: 1;
}

.HPText {
  background-color: #4CAF50;
  color: white;
  font-size: 16px;
  padding: 16px 32px;
}

1 个答案:

答案 0 :(得分:0)

在得出结论之前,您应该始终尝试使用浏览器开发人员工具来检查错误或错误。在css.container全屏显示width: 100%。没有给出任何width就像告诉它包含全屏一样。

如果您希望HPPV或任何图片并排排列,我建议您调整代码,您应该使用浮点数并尝试将两者放在一起它们在一个容器中或具有特定width: 50%的不同容器中并排浮动两个img