Creating an image that adjusts to different screen sizes for optimal viewing on all

Struggling with making a responsive webpage? Let me show you the issue I'm facing with the robot image and message placement.

On a Galaxy S5, everything looks good: https://i.sstatic.net/3Kc3z.png

However, when viewed on a Pixel 2 or other devices, the message gets shifted upwards like this: https://i.sstatic.net/3o3fT.png

It's not just limited to these two devices; the problem persists across different screens. While I've tried using media queries for specific devices, it feels like too much work. Any optimal solutions would be greatly appreciated. Thank you in advance.

If you want to take a look at my code snippet, here's the link: https://codepen.io/Amoocris/pen/vPWOpX

HTML

<div class="header-box">
<ul class="main-nav">
  <li class="main-nav__items"><a class="main-nav__link" href="#">About</a></li>
  <li class="main-nav__items"><a class="main-nav__link" href="#">Projects</a></li>
  <li class="main-nav__items"><a class="main-nav__link" href="#">Contact</a></li>
</ul>
<div class="text">
  <h3 class="name">M.Amine Elwere</h3>
  <h1 class="big-heading">Front-end</h1>
  <h1 class="big-heading-2">Web developer</h1>
</div>
<div class="vector-1">
  <img src="../vector/Png for the web/header minou.png" data-aos="fade-up" class="img-header" alt="">
  <img src="../vector/Png for the web/png-dialogue-2.png"  data-aos="fade-right" data-aos-duration="4000" class="img-dialogue" alt="">
  <h1 class="dialogue"  data-aos="fade-up" data-aos-duration="5000">HEYY!...</h1>
</div>

</div>

CSS

 @media (max-width: 480px) {
   * {
     margin: 0;
     padding: 0;
   }

   body {
     font-family: Roboto;
     color: #33cccc;
     background-color: #ffffcc;
   }

   .header-box {
     width: 100vw;
     height: 90vh;
     background-color: #33cccc;
     -webkit-clip-path: polygon(0 0, 100% 0%, 100% 76%, 0% 100%);
     clip-path: polygon(0 0, 100% 0%, 100% 76%, 0% 100%);
     position: relative;
   }

   .main-nav {
     display: flex;
     list-style-type: none;
     justify-content: space-around;
     width: 100vw;
     text-align: right;
   }

   .main-nav__items {
     text-decoration: none;
   }

   .main-nav__link {
     text-decoration: none;
     font-family: 'Roboto', sans-serif;
     font-weight: bold;
     color: #ffffcc;
   }

   .name {
     font-family: Roboto;
     text-align: center;
     position: absolute;
     top: -7%;
     left: 3%;
     font-size: 1rem;
   }

   .text {
     font-family: Roboto;
     font-weight: bold;
     font-size: 2rem;
     color: #ffffcc;
     position: absolute;
     left: 50%;
     top: 40%;
     transform: translate(-50%, -50%);
   }

   .img-header {
     width: 30%;
     height: auto;
     position: absolute;
     bottom: 0px;
   }

   .img-dialogue {
     position: absolute;
     bottom: 7rem;
     left: 2rem;
   }

/* .vector-1{
  position: relative;
  bottom: 0;
} */

   .dialogue {
     position: absolute;
     font-family: inherit;
     color: inherit;
     bottom: 24%;
     left: 17%;
   }

.big-heading-2{
  margin-top: 10px;
  font-size: 3rem;
  animation-name: moveInLeft;
  animation-duration: 1.5s
}

.big-heading{
  font-size: 3rem;
  animation-name: moveInRight;
  animation-duration: 1.5s;
}


 }

Answer №1

Perhaps consider adjusting the positioning of the .vector-1 div to relative. This way, the .dialogue class will be positioned in relation to its parent div rather than the entire web page. Make sure to also update the position of the .dialogue class accordingly.

Additionally, it's recommended to avoid using more than one h1 element on your webpage. The h1 tag typically represents the title of the page and should only be used once for better SEO and organization.

If you have any further inquiries or need assistance, feel free to reach out!

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

Creating a dropdown menu that includes miniature images: A step-by-step guide

Specifics I am interested in incorporating a small flag to the left of my dropdown menu. I need guidance on the recommended method for achieving this. My Attempt So Far <!-- Dropdown-Menu --> <div class="col-sm-6 drop-down "> S ...

Steps to record and upload a video directly to the server using getusermedia

For my application, I need the user to record a video and have it saved on the server disk instead of downloading it to the client browser. I am currently using getusermedia for this purpose, with the following code: (function(exports) { exports.URL = exp ...

Unsure of the steps needed to configure Ajax

Be sure to read through the entire question as there are two questions presented. As a newcomer to ajax, I am completely unfamiliar with it and despite reading Jquery's Ajax documentation, I'm still unclear on what steps to take. First Question ...

Setting custom domains on Heroku is essential for optimizing the performance and branding of my website

Essentially, when using Heroku, you are provided with a default domain: XXX.herokuapp.com. Personally, I have a collection of REST APIs that I want to configure on a domain called: api.myDomain.com. At the same time, I also have my HTML files (web view) ...

What is the most effective way to programatically display a graphic component (.ts files)?

Currently, I am working on a web application project using Angular 6. In this project, a graphic component is essentially an HTML template paired with logic stored in a .ts file. I have encountered a scenario where, in another typescript file associated w ...

Tips for avoiding background image movement during transitions

How can I prevent the background image from jumping effect during animation looping? What I have already attempted: Switching animation type from transition to position change (left: 0 -> left: -100%) Replacing the background image with a background gr ...

Flex Row with Expansion Panel spacing concern

Experiencing issues with spacing of expansion panels within a flex row. Multiple Mat-Expansion-Panel are inside an ngFor loop, each containing varying amounts of items. When one panel is expanded, the adjacent panel also expands to the same height withou ...

Guide on integrating an HTML and CSS register form in Django

I have successfully created a responsive register and login using HTML and CSS. Instead of utilizing the standard register form and login provided by Django upon configuration, I want to apply my own custom template. To summarize, while I am familiar with ...

React - using dangerouslySetInnerHTML does not display the expected output

When I enter the following text in the textbox labeled "Type Here" AAA: <HEllo> BBB: <HE llo> The desired result should be identical to what is entered in the "Type Here" box. However, the actual result box does not display the same output ...

The clickable functionality of buttons and text labels in Vue is currently not working

When I try to input text into the registration page in vue, nothing happens when I click the register/login button. However, if I press TAB and then enter my password followed by another TAB and ENTER, it works. This is the code snippet for the login-box: ...

Instead of setting a fixed value, vary the background color dynamically

def dynamic_color(value, loop_name, breakpoints, metrics, symbol = ''): facts = [(round(item)) for item in value] metrics += '''<tr><th>'''+ loop_name +'''</th>''& ...

How can I remove the unsightly scrollbar caused by overflow: auto?

I've encountered a problem while working on my website. The inner div #content wasn't expanding to the full size of the page, causing the text to overflow messily over the background image and making it difficult to read. I initially used overflo ...

What methods can we use to transform Bootstrap rows and columns to resemble a table design?

Attempt number one did not work due to padding issues in the columns. Attempt number two also failed, leading me to believe I may be making a mistake somewhere. This is what I am aiming for: https://i.sstatic.net/yTz6o.png Can anyone provide some assis ...

Customize Bootstrap 4 Card Width in Card Decks for a Fixed Number of Cards per Row

My website features a deck of cards, and I must say, they are quite responsive. They adhere to the set amount per row for each resolution and maintain consistent height. However, there is one issue that bothers me - when there are 2 cards in a row, with 2 ...

What are the best ways to integrate jQuery into a React application?

I am in the process of developing a responsive menu for my react app, but I'm facing some challenges as a newcomer to react. In order to achieve the desired functionality, I am trying to incorporate jQuery for menu toggling. However, when I attempt to ...

What is the process for dividing a single row into multiple columns?

Is it possible to split a single row into multiple columns in HTML? | Category | Values | | A | 1 | | B | 2 | | C | 3 | | D | ...

Is it possible to monitor the progress of an order placed via my website as a Flipkart affiliate?

As an affiliate for flipkart, I promote their products on my website. I am interested in being able to track the orders and purchases made by users who are redirected to flipkart from my site. Is it possible for us to obtain the order/purchase id for thos ...

.value not being grabbed from options of selected index

I have a form that includes a select field with the id of "to". My goal is to retrieve the selected value within a JavaScript function. Interestingly, the first time I execute this function, it fails to capture the selected value. However, upon running t ...

Adjust the CSS extension within the about:config settings of Firefox

I've been using the Zotero extension and I want to adjust how TinyMCE handles paragraph spacing. I'm looking to customize the CSS in extensions.zotero.note.css by adding specific CSS rules. The reason I want to make these changes is because I fe ...

The Bootsrap modal fails to open when triggered by a different button

Why does the login button open a signup modal instead of a login modal, even though they are configured in the same way? I renamed the login button to 'loginModel', but it still doesn't work as expected. However, the sign-up button works cor ...