What is preventing my image from moving upwards?

I've been struggling to move this image up, despite trying several methods. I really want it to be aligned horizontally with the PV picture.

I need the HP image to be moved directly upwards so that it aligns horizontally with the PV image.

This is the content of my index.html file:

<!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">World's 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>

This is what I have in my index.css file:

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;
}

Answer №1

Before jumping to conclusions, consider using your browser's developer tools to identify and fix any bugs or errors. In your css, the .container is set to width: 100%, making it full screen. Not specifying a width at all achieves the same result of filling the entire screen.

I recommend adjusting your code if you want HP to be positioned next to PV or any other image side by side. You can achieve this by utilizing floats and placing both images in either the same container or separate containers with specific width: 50%, floating the two img elements side by side.

Similar questions

If you have not found the answer to your question or you are interested in this topic, then look at other similar questions below or use the search

Tips for displaying dynamic images using the combination of the base URL and file name in an *ngFor loop

I have a base URL which is http://www.example.com, and the file names are coming from an API stored in the dataSource array as shown below: [ { "bid": "2", "bnam": "ChickenChilli", "adds": "nsnnsnw, nnsnsnsn", "pdap": " ...

Adjusting image width using jQuery

I have been experimenting with creating a Webgl hover effect for an image. The effect works well, but now I am trying to specify a width for the image within jQuery. new hoverEffect({ parent: document.querySelector('.ticket'), intensity1: 0. ...

Building a Dynamic Web App with PHP and Vue.js

I developed an API using PHP and you can access it through this link: However, I encountered an issue when trying to display the data on the front-end of my Vue.js (Home.vue) file using axios. Below is the code I used: <ul class="ta-track-list" v-if= ...

developing a loading animation with progress indicator in CSS3

I have been working on creating a preloader, but I am having trouble embedding the percentage with the CSS circle. So far, I have tried various plugins without success. Can anyone help me with this issue? Here is my current progress. Below is the HTML co ...

What could be causing justify-content: flex-start; to not function as expected?

Can someone help me with my flexbox navbar? I set the justify-content property to flex-start, but the content inside the container is not aligning correctly. You can see the output and code here: output html, body { backgr ...

"Optimizing XSL stylesheets by implementing conditional row styles to prevent redundant

Is there a way to display rows that are older than 2 years from today in bold without repeating the code? I know the condition I need, but I'm struggling with avoiding duplicating all the code just for a different style. This is the code I have: & ...

After saving a rich field in Microsoft Sharepoint, I noticed that a new "External Class" was automatically added to my CSS

Although I am new to Sharepoint, I have experience in HTML and CSS. I recently created a mini HTML application that changes the pictures of hyperlinks on hover. It works perfectly when run on a normal browser outside of Sharepoint. However, the issue aris ...

Seeking guidance on selecting text using XPath

My HTML document contains the following HTML code: <!DOCTYPE html> <html> <head> <title>page XYZ</title> </head> <body> <p><b>bold text</b> some more text </p> <p>< ...

What is the best way to extract data from dynamically generated radio buttons?

UPDATE I previously attempted the recommended adjustments in the initial response, but encountered issues with radio buttons allowing multiple selections and the label number controlling the top radio button. Subsequently, I have experimented further...I w ...

Utilizing CSS to style text on a menu by applying a specific class to an unordered list element

Is there a method to use CSS to invoke a div id function that will highlight text when the mouse hovers over it? <ul class="sub-menu"> <li id="menu-item-1721" class="menu-item menu-item-type-post_type menu-item-object-page menu-item-1721">< ...

Navigate through a filtered list of parent items with the use of cursor arrows in AngularJS

My form contains an input with a dropdown, where I display JSON data like this: { "title": "Parent #1", "child" : [ {"title": "Child ##1"}, {"title": "Child ##2"}, {"title": "Child ##3"}, {"title": "Child ##4"} ...

Put a watch on a variable as soon as it is set

When initializing a variable, I want to use the $watch function in Angular without it automatically initializing right away. Is there a way to accomplish this? $watch $scope.$watch(function () { return $scope.character.level; }, function (ne ...

Make sure the division remains fixed even when the window is resized

Having a fixed position and bottom set to 0, I want my div to display at the bottom of the window. The issue arises when the window is resized, causing the div to move up and into other elements. For instance, when opening the console box in Chrome, the f ...

Ways to effectively hide one window or pop-up upon clicking another

I am working on creating an interactive website for my close circle of friends and family. One of the key features is to have a button that displays their biography when clicked. What I'm aiming for is that when a different bio is selected, the previo ...

Modify the color of the active class in Bootstrap

I am trying to modify the color of the active class in my HTML code as I create a nav sidebar. Here is the snippet from my code: <div class="col-sm-2"> <ul class="nav nav-pills nav-stacked nav-static"> <!--stacked for vertic ...

What could be causing jQuery animate to malfunction on mobile devices when a viewport is present?

Everything seems to be working fine on my desktop webpage, but when I try it on mobile, there is no scroll... $("HTML, BODY").animate({ scrollTop: 500 }, 1000); This post suggests that mobile devices may not scroll on the body, but on the vi ...

Utilizing SEO and incorporating special characters like !# in a website's URL

I came across an interesting concept about designing a website that utilizes AJAX to load each page section without compromising SEO. It involved incorporating !# in the URL, similar to the approach adopted by Twitter. However, I've been unable to loc ...

Populate a MySql database with 2 input values

I am facing an issue with inserting values into MySql from a table. When trying to insert two values, only one gets stored in the database and the other remains empty. Here is the structure of my MySql table: Below is the HTML code for my table: <tab ...

Data structure designed specifically for a drawing tool application

Currently, I am in the process of developing a unique sketching application using the HTML5 Canvas element. Despite my progress, there is one particular challenge that has stumped me. The main concept of the application involves allowing users to manipula ...

How can I keep the CSS3 animation playing even after the hover state ends?

When hovering over the small menu logo on my site, there's a subtle wiggle effect that I really like. However, I would prefer if the animation played all the way through before repeating. Here's the code I'm currently using: Here is my code ...