HTML - What steps can I take to ensure my website displays appropriately on various screen sizes?

Currently, I'm having some trouble with the appearance of my website. Let me explain:

I've written some basic code (Please note that this code includes margins. I'm not sure if this is causing the issue) but the content doesn't display nicely on different screen sizes. Feel free to run the code in your browser to see what I mean:

HTML

<!doctype html>
<html lang="en">
<head>
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<link href="css/styles.css" rel="stylesheet" type="text/css">
<link href="https://maxcdn.bootstrapcdn.com/font-awesome/4.7.0/css/font-
awesome.min.css" rel="stylesheet" integrity="sha384-
wvfXpqpZZVQGK6TAh5PVlGOfQNHSoD2xbE+QkPxCAFlNEevoEH3Sl0sibVcOQVnN" 
crossorigin="anonymous">
<meta charset="UTF-8">
<title>Portal</title>

</head>
<body>

<nav>
        <ul>
            <h3 style="margin:15px;" class="logo">MYWEBSITENAME</h3>
            <li><a class="navlink" href="#">Home</a></li>
            <li><a class="navlink" href="#">About</a></li>
            <li><a class="navlink" href="#">Templates</a></li>
            <li><a class="navlink" href="/css-library">CSS Library</a></li>
            <li><a class="navlink" href="#">Updates</a></li>
            <li><a class="navlink" href="#">Downloads</a></li>
        </ul>
    </nav>


  <div class="content-left">
       <h1>Ocelot <strong class="tag-greentheme">1.0</strong></h1>
       <h3 class="margin-para">Let me set things straight: clicking every download button for all our libraries can be tiresome. That's why we created something special called <em>Ocelot</em>. Ocelot combines all our libraries into one convenient package. Get ready for <em>ocelot!</em> - Current version: 1.0.</h3>
       <hr>

        </div>


  <div class="details">
        <h1>GET OCELOT</h1>
        <button class="button-greentheme">MORE INFO</button> <button 
class="button-graytheme">SAFE LINK IT!</button>
    </div>

<div class="content-left">
       <h1>Bibrary <strong class="tag-greentheme">1.0</strong></h1>
       <h3 class="margin-para">Introducing the brand new CSS library - Bibrary. This is our first CSS library and it covers a wide range of buttons. Keep an eye on this one as it may receive updates as frequently as five times a year!</h3>
        </div>


  <div class="details">
        <h1>GET BIBRARY</h1>
        <button class="button-greentheme">MORE INFO</button> <button 
href="/bibrary" class="button-graytheme">SAFE LINK IT!</button>
    </div>

</body>
</html>

I have specified margin-left:30px; and margin-right:30px; Please provide feedback if you disagree with this design choice.

Answer №1

Consider utilizing the robust Bootstrap Framework as it is highly favored and widely used for creating responsive designs. Visit getbootstrap.com for further information and resources. Additionally, there are numerous helpful tutorials available on YouTube for mastering Bootstrap.

If you prefer a more straightforward approach without using a framework, explore the option of utilizing @media queries with pure CSS. Extensive documentation can be found through a simple search on Google.

Answer №2

To implement responsive design, utilize media queries within your CSS stylesheet. An example of how to do this is shown below:

@media only screen and (max-width: 768px) {
    body {
        color: red;
    }
}

Answer №3

Here's a code snippet for you to try:

<!doctype html>
<html lang="en">
   <head>
      <meta name="viewport" content="width=device-width, initial-scale=1.0">
      <link href="css/styles.css" rel="stylesheet" type="text/css">   
    <link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap.min.css" integrity="sha384-BVYiiSIFeK1dGmJRAkycuHAHRg32OmUcww7on3RYdg4Va+PmSTsz/K68vbdEjh4u" crossorigin="anonymous">
      <meta charset="UTF-8">
      <title>Portal</title>

<style>
.content{
    border-bottom: 1px solid #000;
}
</style>


   </head>
   <body>

         <nav class="navbar navbar-default">
            <div class="container-fluid">
               <div class="navbar-header">
                  <button type="button" class="navbar-toggle collapsed" data-toggle="collapse" data-target="#navbar" aria-expanded="false" aria-controls="navbar">
                  <span class="sr-only">Toggle navigation</span>
                  <span class="icon-bar"></span>
                  <span class="icon-bar"></span>
                  <span class="icon-bar"></span>
                  </button>
                  <a class="navbar-brand logo"  href="#">WEBLEARN</a>
               </div>
               <div id="navbar" class="navbar-collapse collapse">
                  <ul class="nav navbar-nav">
                     <li><a class="navlink" href="#">Home</a></li>
                     <li><a class="navlink" href="#">About</a></li>
                     <li><a class="navlink" href="#">Templates</a></li>
                     <li><a class="navlink" href="/css-library">CSS Library</a></li>
                     <li><a class="navlink" href="#">Updates</a></li>
                     <li><a class="navlink" href="#">Downloads</a></li>
                  </ul>
               </div>            
            </div>          
         </nav>
         <div class="container-fluid">
            <div class="col-xs-12 content">
               <div class="col-xs-12 col-sm-6 content-left">
                  <h1>Owl <strong class="tag-greentheme">1.0</strong></h1>
                  <h3 class="margin-para">Interested in time management? Meet Owl - the library that combines all our resources in one place.
                     Get rid of the clutter and welcome efficiency with Owl! Current version: 1.0.
                  </h3>

               </div>
               <div class="col-xs-12 col-sm-6 details">
                  <h1>GET OWL</h1>
                  <button class="button-greentheme">MORE INFO</button> <button 
                     class="button-graytheme">CLICK HERE!</button>
               </div>

                </div>
               <div class="col-xs-12">
               <div class="col-xs-12 col-sm-6 content-left">
                  <h1>Zebra <strong class="tag-greentheme">1.0</strong></h1>
                  <h3 class="margin-para">Introducing Zebra - the latest CSS library launched by us. Covering a wide range of button styles,
                     Zebra promises to keep your design game strong. Stay tuned for updates as Zebra evolves over time!
                  </h3>
               </div>
               <div class="col-xs-12 col-sm-6 details">
                  <h1>GET ZEBRA</h1>
                  <button class="button-greentheme">MORE INFO</button> <button 
                     href="/zebra" class="button-graytheme">EXPLORE NOW!</button>
               </div>
            </div>
         </div>

   </body>
</html>
<script  src="https://code.jquery.com/jquery-2.2.4.min.js" integrity="sha256-BbhdlvQf/xTY9gja0Dq3HiwQF8LaCRTXxZKRutelT44=" crossorigin="anonymous"></script>
<script src="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/js/bootstrap.min.js" integrity="sha384-Tc5IQib027qvyjSMfHjOMaLkfuWVxZxUPnCJA7l2mCWNIpG9mGCD8wGNIcPD7Txa" crossorigin="anonymous"></script>

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

What is the best way to create a div that horizontally scrolls and contains multiple other div elements?

I've set up a div that contains other divs, including images and text. My goal is to make the main div scrollable horizontally while aligning the inner divs using inline-block. However, when I apply: overflow-x: scroll; The main div ends up with tw ...

Issue with Slider Width in WP 5.6 editor and ACF Pro causing layout problems

Is anyone else experiencing a specific issue after updating to WP 5.6? Since the update, all my websites are facing problems with rendering a Slick Slider in the Block Editor. Interestingly, everything looks fine on the front-end. The root of the problem ...

When I log out and hit the back button, the PHP page continues to display without any changes

After logging out of my PHP session and being redirected to the login page, I am facing an issue where pressing the back button shows me the previous page without requiring a login. How can I fix this problem? Thank you in advance. index.php <form sty ...

PHP consistently selects the final radio button element

Having an issue with submitting data from radio buttons to an ajax request for database transfer. -html <form class="siteInfo" action="ajax/site.php?nr=<?php echo $_GET['nr']; ?>" method="POST"> <input type="radio" name="transpor ...

Obtain an Element Using Puppeteer

Currently grappling with a sensitive issue concerning puppeteer. The HTML structure in question is as follows: <tbody> <tr rel="0" class="disabled" id="user6335934" class="odd"> ...

Adjust the overall cost according to the quantity using jQuery or JavaScript

I'm currently working on a project that involves input fields for Product Price, Quantity Form Field, and displaying the Total price. My goal is to have the Total price automatically update based on the product price and quantity with jQuery. I am loo ...

Icon-enhanced Bootstrap dropdown selection

I have a unique select dropdown using Bootstrap where I want to display icons like the example below: https://i.sstatic.net/dZmTS.png <!DOCTYPE html> <html> <head> <script src="/scripts/snippet-javascript-console.min.js?v=1"& ...

A single feature designed to handle various elements

I currently have this HTML code repeated multiple times on my webpage: <form class="new_comment"> <input accept="image/png,image/gif,image/jpeg" id="file" class="file_comment" key=comment_id type="file" name="comment[media]"> <spa ...

The layout of the keyboard in Cordova has been altered

Just starting out with my first Cordova app and I'm working on a simple login form. The issue I'm facing is that whenever I click on an input element, the keyboard pops up and completely messes up my layout, which should be straightforward. Has ...

Is there a way to prevent mouse wheel scrolling on a React "number" input field?

Currently, I am encountering an issue with MUI type="number" textfields. When I focus on the field and then scroll the mousewheel, the input value changes unexpectedly. I have looked into adding a blur function after scrolling to prevent this, but I would ...

Utilizing Selenium IDE and XPath to confirm that a checkbox is selected only when the associated label contains certain text

I need assistance in creating an Xpath query to validate if a specific checkbox is checked within the nested divs of the panel-body div. My goal is to ensure that a checkbox with the label "Evaluations" contains the class "checked". Below is the snippet of ...

Maximizing performance with internal Bootstrap?

An interesting concept to consider is that the fastest website could actually be an empty webpage. Each additional piece of data added compromises performance, yet it's the server's responsibility to send all the code to the client. When using ...

Issue: Unable to create the restangular module because: the variable '_' is not defined

Upon integrating Restangular into an existing website, I encountered a JavaScript error that stated: Failed to instantiate module restangular due to: '_' is undefined I'm unsure of what this means. Can anyone clarify why '_' is ...

Arranging input fields for different languages

I recently inherited a product that has been developed using AngularJS, and I have a query related to localization. Within the HTML code, there are two input fields of type 'input-number' - one for entering the number of days and another for spe ...

Initially, my PDF file does not get selected, except in the Internet Explorer browser

I am currently facing an issue with selecting PDF files in Internet Explorer. The process works smoothly in Google Chrome, but I encounter a problem when trying to select PDFs in IE. Specifically, when I attempt to select a PDF for the first time in Inter ...

CSS for Adjusting Parent Height Based on Child Content

I've been working on adjusting the height of the parent class to fit the child class perfectly without overflowing Here is a snippet from my CSS file: Parent &__video position: relative; width: 471px; background: red; border-radius: 12px ...

The CSS property `touchmove pointer-events: none` appears to have a malfunction on Chrome for Android version 4.4 / ChromeView

For my project, I am utilizing CSS pointer-events to allow touchmove events to pass through a transparent div. This method has been effective on most platforms except for Chrome on Android. I am curious if this is a known issue with Chrome and if there are ...

The Oracle Apex Login Interface with a Touch of Customized Styling

Currently, I'm working on creating a login page in Oracle APEX. While modifying the icon using CSS code, everything seems to be falling in place except for this one particular line: .t-Login-logo { background-image:url(#APP_FILES#LogoUpdated.jpg); bac ...

I am looking to bring in just the tables from a different html/php page

I am currently working on a webpage that includes a php library, header, and other elements. I only need to import specific tables and information from this page onto another screen display, with the tables arranged side by side instead of vertically. My ...

script code to limit selection of dates within a predefined range

I'm seeking assistance to limit my customers from selecting a date beyond 10 days in advance. Although I previously had a code that functioned properly when there were more than 10 days left in the current month, it is now ineffective. This is becaus ...