The single page design lacks responsiveness

I'm having trouble making my under construction html layout responsive for screens with a size of 400px and below. The images and container don't stretch to 100% width as I want them to.

The container currently has a fixed width of 400px, so the max-width property is not behaving as expected.

FULL HTML

<!DOCTYPE html >
<html>
<head>
<title>some title</title>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8"> 
<style>
    body {
        font-family: 'Arial', serif;
        width: 100%;
        height: 100%;
    }
    .container {
        padding: 10px;
        text-align: center;
        margin: 0 auto;     
        max-width: 400px;   
    }

    .container img {
        margin: 50px 0;
        display: inline-block;
        width: 100%;
        height: auto;
    }

    p { 
        font-size: 16px;
    }

    a {
        color: red;
    }

</style>
</head>

<body>

<div class="container">
    <img src="https://s3-us-west-1.amazonaws.com/powr/defaults/image-slider2.jpg">
    <h1>some text</h1>
    <p>bla bla bla some text </p>
    <img src="https://s3-us-west-1.amazonaws.com/powr/defaults/image-slider2.jpg">
</div>

</body>
</html>

body {
  font-family: 'Arial', serif;
  width: 100%;
  height: 100%;
}

.container {
  padding: 10px;
  text-align: center;
  margin: 0 auto;
  max-width: 400px;
}

.container img {
  margin: 50px 0;
  display: inline-block;
  width: 100%;
  height: auto;
}

p {
  font-size: 16px;
}

a {
  color: red;
}
<div class="container">
  <img src="https://s3-us-west-1.amazonaws.com/powr/defaults/image-slider2.jpg">
  <h1>some text</h1>
  <p>bla bla bla some text </p>
  <img src="https://s3-us-west-1.amazonaws.com/powr/defaults/image-slider2.jpg">
</div>

Answer №1

Include the following code in your head section:

<meta name="viewport" content="width=device-width, initial-scale=1">

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

Attempting to pass HTML content from a Laravel controller to display in data tables

Issue Description I am trying to send HTML tags to a table using editColumn but it is not working. AddColumn works fine for adding HTML code to a column, but editColumn does not display the HTML elements as expected. My question is how can I successfully ...

When the OnSubmit function is called, it triggers three other functions and then verifies the return types. However, one of the functions is failing to be

Creating a form that collects user input, and upon submission triggers the check_three_func() function <form method="post" action="register_action.php" id="register_form" name="register_form" onsubmit="return check_three_func()"> <br> &l ...

Why are my cursor and my drawing line on opposite sides?

I've been working on a JavaScript drawing app, but I'm facing an issue where the drawn elements are not aligned with my cursor. The positioning seems off, especially when moving to the right or up on the canvas. As I move towards the furthest lef ...

Verification checkbox in Html5 is mandatory

I have created an input checkbox that contains array values, resulting in multiple rows being generated in a table. However, the issue I am facing is that all checkboxes need to be checked in order to submit the form. This means I cannot submit the form un ...

Div with Sticky Header and Scrolling Ability

I am working on a project that involves creating a scrollable div with "title" elements inside. I want the title element of each section to stick to the top of the div as I scroll, similar to how a menu sticks to the top of a webpage. An example of this ca ...

Ensure that PHP does not automatically add a closing tag

After appending the following string to an array in PHP and displaying it, $spineArray[$i]="<itemref idref='part-$i' linear='yes'/>"; The output displays with an unexpected closing tag. What is causing this automatic addition of ...

Internet Explorer 9 is implementing a conditional stylesheet designed for IE7

In order to address certain issues with older versions of Internet Explorer, I have included additional stylesheets as follows: <!--[if IE 8]> <link rel="stylesheet" href="/CallCentre/ServiceCloud/Content/IE8.css"> <![endif]--&g ...

Having trouble incorporating transitions into the hover effect

Currently, I am working on a project using React and Tailwindcss. The issue I am facing involves creating a card with shadowed text that only appears when hovered over an image. I want to make the hover effect smoother by adding a transition class, but I a ...

Tips for utilizing the value retrieved from foreach within ng-repeat using angularjs

In order to display the field "seconddate" only if it is greater than "firstdate", a function needs to be implemented that will return true or false based on the comparison. The date format is in dd mmm yyyy (e.g., 22 Nov 2017). However, it is unclear how ...

Leveraging the Power of jsPDF in Your Google Apps Scripts

Is it feasible to integrate jsPDF into a Google Apps Script project? I am attempting to create documents using templated HTML, but certain CSS styles like background-color do not translate to PDF when using the getAs() function. Given the limitations of ...

Transform audio file into a base64 encoding

I am currently developing a Phonegap application for a friend that will allow users to record audio on their phone, save it to the browser's local storage, and then upload it at a later time. As far as I know, local storage does not support storing b ...

The function did not execute properly, resulting in the express route returning no value

Encountering some issues with Express routes that are behaving inconsistently despite having identical code execution. The goal is to have a client application make API calls like this: async search(){ const query = this.$refs.searchInput.value; ...

Is there a way to achieve a page-turning effect in HTML5

Hello there! I was wondering if it's feasible to create a flipping page effect similar to a book in HTML5. If it is possible, could someone please explain how it can be achieved? Appreciate your assistance ahead of time! ...

Load a variety of tiles to create a unique style and background for the

Currently, I am using this function to randomly retrieve an image. <script> window.onload = choosePic; var myPix = new Array( "https://ry3yr.github.io/OSTR/Diarykeepers_Homepage/extrafiles/images/bgfiles/cool_stuff_anim.gif", "https:// ...

Accessing CSS content from a bundle within the code of an ASP.NET MVC website

I have a website that utilizes bootstrap along with a customized bootstrap theme. The website is designed to send notification emails to its users upon certain actions being triggered. For these notification emails, I want the content to be in well-format ...

Creating an input field within a basic jQuery dialog box is not possible

Can anyone assist me in adding an input box to my dialog box? I am working with jquery-ui.js. Here is the code I currently have: $(document).on("click",".savebtn",function(). { var id = $(this).attr("id"); $.dialog({ ...

Guide to utilizing JavaScript for a basic gaming experience

Looking to incorporate multiple divs that will vanish upon being clicked, while also increasing the score by 1 through javascript. Any suggestions on how to accomplish this? ...

Select two images and simultaneously move them around on a webpage

Looking for a way to replicate the functionality shown in this image - when I drag one map, another one should automatically move as well. Additionally, the downtown map needs to be contained within the mobile frame. The two map images are located in sep ...

Choose tag using position in a sequence

I am working on updating the label text "E-mail" to say "User Name" in this HTML markup. The only tool I have access to for this task is jQuery. <div class="foo" style="border:1px solid #444"> <span class="field-with-fancyplaceholde ...

What is the best way to locate an element using text in xpath?

Having an issue with this HTML source code: <td class="specs_title"> Processortype <a href="#" class="info-link"> <img src="x.jpg" title="" height="16" alt="" width="16" /> <span class="info-popup"> <span class="hd">Processor ...