Stylish Responsive Design with HTML and CSS Centering

I am tasked with creating a landing page that features an image at the top with text, followed by a couple of videos and a 2-pixel strip line image that must stay at the bottom.

<html>
...
<body>

<img src="topimage.png" alt="" />

<table>
 <tr>
<td>Video 1 here</td>
<td>Video 2 here</td>

<img src="2pixelhightimage.png" alt="" />

The goal is for the content to be centered and responsive, adjusting in size based on the screen resolution. How can this be achieved?

Answer №1

If you want to easily center your content, simply create a wrapper and set the left and right margin to auto using percentages instead of pixels.

<div class="wrapper">

 <img src="topimage.png" alt="">

 <!-- Avoid using tables for layout - opt for divs instead -->
 <table>
  <tr>
   <td>Video 1 here</td>
   <td>Video 2 here</td>
  </tr>
 </table>

 <img class="fixed" src="2pixelhightimage.png" alt="">

</div>

Next, add the following CSS:

.wrapper { margin: 0 auto;}
img { max-width:100%; height:auto;}
.fixed {position:fixed; bottom:0;}

Answer №2

Is this layout suitable for the general design?

<div class="wrap">
<div class="content">insert content here</div>
</div> 

.wrap
{
width:100%;
background:gray;
}
.content
{
width:80%;
margin:0 20%;
background:green;
}

Check it out on jsFiddle!

Answer №3

Enclose the content within a wrapper div

<div id="content-wrapper">
    <!-- your content goes here -->
</div>

Style the wrapper as follows:

#content-wrapper {
    width: 980px; /* Set maximum width for the content */
    max-width: 100%; /* Make it responsive */
    margin: 0 auto; /* Center the wrapper horizontally */
}

Avoid using tables for videos. Use this structure instead:

<ul class="video-list">
    <li class="single-video">
        <!-- video content here -->
    </li>
    <li class="single-video">
        <!-- video content here -->
    </li>
</ul>

Apply CSS to the video list:

.video-list {
    list-style: none; /* Remove bullets */
}
.video-list .single-video {
    display: inline-block; /* Arrange videos side by side with available space */
    width: 245px; /* Divide the site width of 980px into 4 equals parts */
}

To add a sticky strip line at the bottom, use this code:

<div class="bottom-strip-line"></div>

And style the strip line with the following CSS:

.bottom-strip-line {
    position: fixed;
    bottom: 0;
    width: 100%;
    height: 2px;
    background: url(path/to/image.jpg) repeat-x;
}

If you need more specific guidance, please provide additional context ;-)

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

Unable to send messages through contact form - Issue with HTML/CSS

I had successfully achieved the desired outcome before, but now I am facing difficulties replicating it. The linked image displays my intended result versus what is currently happening. https://i.stack.imgur.com/QUCuN.png What could be causing this issue ...

Interactive JavaScript button that navigates me to a document without the need to click

I'm facing an issue with my small project. I've been learning javascript and managed to create a script that calculates the square of a number provided by the user. var checkIt = function(){ var theNumber = Number(prompt("Please enter a number ...

Tips for applying a custom design to your MUI V5 styled component

How do I customize the style of a button component in MUI V5? I've been trying to combine old methods with the new version, but it's not working as expected. import { Button } from "@mui/material"; import { styled } from "@mui/mate ...

Ways to extract a specific line of text from HTML code

Can someone help me extract a specific line from an HTML code using Python? For instance, in this website: The snippet of code is as follows: var episodes = [[8,54514],[7,54485],[6,54456],[5,54430],[4,54400],[3,54367],[2,54327],[1,54271]]; I am lookin ...

Use jQuery and AJAX to update the current HTML content only when the image has finished loading

I am attempting to load a .php file that contains a 2Mb image into a specific div. While I can make this work with ajax, my issue is that I only want the content of the current div to be replaced with the new one once the image finishes loading. Currently ...

data not being transferred successfully to the SQL input from forms

The data from this input form is not being properly transferred to the SQL database when using the sqlAddUser.php file available at pastebin.com/W9BH0D3s. The form includes the following fields: <form action="sqlAddUser.php" method="post"> <div c ...

Information from contact forms gets inputted into the URL

Currently, I am in the process of developing a website and implementing a Contact Form that allows customers to email me directly. To test if the mail function is working correctly, I am using a Test Mail Server listening on Port 25 through a WAMP server v ...

Tips for automatically adjusting the height of the footer

Is there a way to dynamically adjust the height of the footer based on the content length inside the body? I've been exploring solutions like setting the position of the footer as "fixed," but it seems to stay at the bottom of the screen, which is no ...

AngularJS controller does not trigger ngRoute

I have developed a basic application to experiment with ngRoute functionality. The main page, index.html, contains a single link leading to a separate page named "informationdisplay.html". Despite configuring the route within the controller of the main pag ...

Struggling with setting up a PHP and Ajax registration and login system

Struggling with my code and in need of assistance. Desperately trying to set up a register form where users can input their username and password to sign up. Planning to utilize ajax, however, the integration seems faulty. For testing purposes, I tried ech ...

Simple JavaScript numeric input field

Hey there, I'm a beginner learning JavaScript. I'm currently working on creating a program that adds numbers input through text fields. If you want to check out the HTML code, visit this link on JS Fiddle: http://jsfiddle.net/fCXMt/ My questio ...

Is there a way to create a dropdown menu that transforms into a burger icon on smaller screens, while still housing all of my navigation items within it?

I'm currently working on a segment of my header that includes a navbar with 3 links, as well as a dropdown menu listing additional functionalities. Here is the current code I have: <div class="col-md-4 pt-4"> <nav class="navbar ...

What is the best way to determine if a PHP string has identical consecutive letters?

Can you help me figure out why my code isn't working? $pattern_c_sap='/\.\-/'; $local='.................'; $local_array = explode( '', $local ); for($i=0; $i<=$local_length; $i++){ if(preg_match($pattern_c_ ...

Tips on eliminating the background of a div nested within another div

<div class="white"> <div class="transparent"> ---- </div> <div class="content"> ---- </div> </div> I am working with a parent div .white that has a white background color. Inside this parent div, there are mul ...

Display the element when it becomes visible in the user's viewport as they

I've been struggling to implement a feature where an element is shown on scroll when it's in the viewport and hidden when it's not. However, despite my efforts, I haven't been able to get it working properly. Here's what I have so ...

Steps for displaying the output of a post request in printing

I am currently working on creating a basic search bar functionality for daycares based on user input. I am utilizing a post request to an API and receiving back a list of daycares that match the input. Below is the code snippet: <template> <div ...

Utilize Google Autofill to easily populate address fields in a form

I've come across several autofill address codes, but I'm looking to integrate a Post function that would allow me to post the obtained data to a PHP page. Is there anyone who can assist with the javascript or HTML code to achieve this? HTML Cod ...

Solution for accessing the callee function in JavaScript slide down operation

While exploring a tutorial from CSS Tricks about animating section height, I came across a solution that I would like to implement in my Angular 2 application. Here is the function responsible for expanding sections in my app: expandSection(element) { / ...

Is there a way for AJAX to dynamically insert new rows into a table?

I am seeking assistance in dynamically adding rows to an HTML table using AJAX whenever additional records are retrieved from a database query. My workflow involves utilizing Python Flask and Pandas to generate a dataframe containing information about node ...

Placing an exit button beside an image for easy navigation

Here is a snippet of my code: <style type="text/css"> .containerdiv { position:relative;width:100%;display:inline-block;} .image1 { position: absolute; top: 20px; left: 10px; } </style> <div class="containerdiv"> <ima ...