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

The downloaded image exceeds the desired size

ISSUE Currently, I am developing an application that fetches data from a JSON file uploaded on a website. The downloaded information displays correctly except for one problem. There is an UIImageView with dimensions of 54x54, and when I try to download th ...

The importance of CSS styling links: the difference between a:link, a:visited and simply using a

Curious about the difference between using: a { ... } versus a:link, a:visited { ... } ...

Executing Python output in HTML with Django

I am currently working on a Django project and in the views.py file of my app, I have some outputs stored in a dictionary. The code snippet from views.py is as follows: from django.shortcuts import render def allblogs(request): a = request.GET[' ...

Do you know the term for when JavaScript is utilized to display specific sections of a png image?

Imagine you have an image file in the format of a PNG which includes various icons intended for use on a website. How can JavaScript be utilized to choose and showcase a specific icon from that image? It's a technique I've observed in practice, b ...

I want to create a feature in Angular where a specific header becomes sticky based on the user's scroll position on the

When working with Angular, I am faced with the challenge of making a panel header sticky based on the user's scroll position on the page. I have identified two potential solutions for achieving this functionality. One involves using pure CSS with pos ...

Guide to triggering an event when two distinct keys are pressed simultaneously (Using HTML5 and Javascript)

I'm looking to have my character jump whenever I press any key on the keyboard. Is there a method to achieve this using "case..." functions? Thanks! Jordan ...

Is there a way to detect the completion of the fadeout animation before calling a function?

I am trying to create a toast message using jQuery. When the "show" class is appended to the div, I want the toast message to fade in and then fade out after a few seconds. Once the fade-out animation is complete, I need to remove the "show" class. This ...

Tips for expanding an input field to span across two td elements

I am attempting to design a simple form. The issue I am encountering involves creating an input field that spans two td's in the second row of my table. Despite using the colspan="2" attribute within the td tag, the input field does not expand over tw ...

Tips for filling in the values for the options in a select dropdown menu

Currently, I am facing a strange bug related to the select element. Whenever I open the dropdown, there is always a mysterious black option at the top. This is how my HTML looks like: This particular element is part of my test controller. <select ng- ...

Guide on creating uniform heights and widths for images with varying dimensions utilizing CSS (and percentage values)

Is there a way to ensure that all images maintain the same height and width using CSS percentages, rather than set pixel values? I'm working on displaying images in circles, where most are uniform in size but a few outliers distort the shape. The wide ...

Issue with fixed positioning not behaving as intended while scrolling downwards

I am facing an issue with an element that has the .it class and I want to keep it fixed on the screen using the position: fixed CSS property. However, as I scroll down the page, the element moves along with the screen instead of staying in place. Below is ...

Developing a webpage that navigates seamlessly without the hassle of constantly refreshing with

I am in the process of creating a website that is designed to run everything within the same file, but I am unsure about how to locate study materials for this project. For example: In a typical website scenario -> If I am on index.php and I click on ...

Discovering the source of the parent link within html.tpl.php

Is there a way to determine the parent page title within html.tpl.php? I need this information to change the background image based on the selected parent link. Here is the URL for reference: Thank you, Ron I couldn't find a solution to this problem ...

Modify content or display picture within accordion panel based on its identifier

In my view, I have a model representing a list of items. Each item has a unique ID, which is included in the H2 header tag. The details of each item are displayed in a div below the header. Initially, there is an image within the header that is set to disp ...

Let's discuss how to include the scrollTop option

I am new to coding and I need help adding a scrollTop margin of +100px to my code. The page already has some top margin but I can't seem to locate it. I'm also having trouble finding where the margin-top is being set in the JavaScript file. /*** ...

Utilizing AJAX for XML data parsing

I need help with formatting XML data into a table. The code I've written isn't working as expected. The XML data is structured in branches, causing it to not display correctly. Can someone assist me in fixing this issue? <!DOCTYPE html> &l ...

Having difficulty setting up page titles in AngularJS

Using AngularJS, I am developing a web app that is not a single page application but all the code is contained in one file- index.ejs. The setup for my index.ejs file looks roughly like this: <head> <title> Main Page </title> </he ...

Alternating row colors using CSS zebra striping after parsing XML with jQuery

After successfully parsing XML data into a table, I encountered an issue with applying zebra stripe styling to the additional rows created through jQuery. Despite my efforts to troubleshoot the problem in my code, I remain perplexed. Below is a snippet of ...

Deactivate the button until the input meets validation criteria using Angular

What I'm trying to achieve is to restrict certain input fields to only accept integer or decimal values. Here's the code snippet that I currently have: <input type="text" pattern="[0-9]*" [(ngModel)]="myValue" pInputText class="medium-field" ...

What is the best way to store article IDs using Javascript or HTML?

On my web page, I have a collection of links that users can interact with by clicking and leaving comments. These links are loaded through JSON, each with its unique identifier. But here's my dilemma - how can I determine which link has been clicked? ...