Reduced to a smaller size, my HTML/CSS page compresses the images and text, causing the formatting to become distorted

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Strict//EN" "http://www.w3.org/TR/html4/strict.dtd">
<html>
<head>
    <meta name="generator" content="HTML-Kit Tools HTML Tidy plugin">
    <link href="layout.css" rel="stylesheet" type="text/css">
    <title></title>
</head>
<body>
    <div class="square" font=10px>
        <p></p>
    </div>

    <div id="wrapper">
        <img class="A" src="download.jpg" alt="Solar Panels"/>
        <img class="B" src= "wind.jpg" alt="Windmills"  />
        <img class="C" src= "biomass.jpg" alt="Biomass"  />
        <img class="D" src= "renewable.jpg" alt="Renewable Energy"  />
    </div>  

    <hr>

    <div id = "bottom">
        <p>Contact:*********@gmail.com</p>
    </div>
</body>
</html>

Sharing the code and css for a webpage layout.

<style type="text/css">
p {
color:#f5f5dc;
font-size:50px;
text-align: center;
margin-top: 20px; 
}
body{
background-color:#fffacd;
font-size:100%;
min-width:800px;
}
.square{
    height: 100px;
    width: 100%;
    position:relative;
    left:-20px;
    border: 2px solid black;
    border-radius: 5px;
    background-color:#0066cc;
    font-size:1.0em;

}
#wrapper{
width:100%;
margin-top: 40px;
margin-bottom: 40px;
}
.A, .B, .C, .D{
width:300px;
height:200px;
float:left;
border:1px solid black;
margin-right:10px;
margin-bottom:40px; 
}
.D{
width:270px;
}
#bottom p{
 color:black;
 font-size:15px;
}
</style>

An inquiry about minimizing the code without squishing elements together is raised. Modifications attempted include using containers.

The issue arises when the page size is reduced, causing elements to overlap and create a messy appearance despite looking fine in full-screen mode.

Answer №1

If you want to make your website responsive, consider using the responsive CSS classes provided by Bootstrap. You can easily format your content by applying these classes. http://getbootstrap.com/2.3.2/

For instance, you can use the following code snippet:

<div class="row-fluid">
  <div class="span4">...</div>
  <div class="span8">...</div>
</div>

Answer №2

One solution could be to set a minimum width for the body element.

TAKING ACTION

<body style="min-width: 800px;">

ALTERNATIVELY, IN YOUR STYLESHEET

body {
    min-width: 800px;
}

You can adjust the value of 800px to your desired minimum width. This way, if the browser window shrinks below that specified width, scrollbars will appear.

Answer №3

Kindly reference the fiddle and make necessary updates,

I have rectified some minor errors, including a missing closing div tag,

The use of strict DTD in the header is primarily responsible for disrupting the formatting...

If you are still learning, consider using transitional or loose DTD instead,

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
   "http://www.w3.org/TR/html4/loose.dtd">

I believe this should resolve the issue, but if it persists, please update the fiddle and provide the new link with all codes.

Thank you for updating the CSS code, upon reviewing your CSS adjustments, I have identified that the problem lies with the float property. I have made the necessary changes in my fiddle, which now functions properly on Google Chrome Browser. Please inform me if any issues persist with specifics.

Answer №4

It appears that your tags are not responsive in your views, but there is a simple solution. You can easily make them responsive by downloading Bootstrap CSS and linking it in your HTML.

 <!DOCTYPE html>
 <html>
   <head>
     <style> 
        <link rel="stylesheet" type="text/css" href="bootstrap.css"> 
        <link rel="stylesheet" type="text/css" href="bootstrap_responsive.css"> 
    </style>
   </head>
   <body>
    <p>hello world.</p>
   </body>
 </html>

Don't forget to check out the Bootstrap fluid grid system for more details on making your design responsive.

If you prefer not to use Bootstrap, another option is PureCSS, which can be found at

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

How can I retrieve text instead of HTML using jQuery.get?

I'm facing an issue where I am trying to retrieve data from another site using the code below: jQuery.ajaxSetup({ crossDomain: true, dataType: "jsonp text" }); jQuery.get(url, function(rawContent) { console.log(rawContent); }); However, ...

What is the process for adjusting the button color within Bootstrap?

Is it possible to customize the colors of Bootstrap buttons beyond the default options? I'd like to explore more color choices for my buttons. ...

CSS enables the colour of text to gradually fill from the left to the right in

I want to create an animation for the text that has the class ".popUpWord". When hovering over it, I would like the color of the text to change gradually from left to right. <span class="popUpWord">hello</span> What I'm aiming for is a s ...

The sticky position is failing to function properly when I set the float property to the left on other

I noticed that the position sticky for the header stops working once I add float:left to another element. The tricky part is, if I remove the float:left from main>div, the sticky header works fine. Despite my efforts to find a solution through Google, n ...

Expanding and collapsing Javascript accordion when a new tab is opened

Is there a way to prevent previously opened accordions from remaining open when opening another accordion? Any help on fixing this issue would be greatly appreciated. Thank you! let acc = document.getElementsByClassName('ac-btn'); let i; fo ...

Take away the attention from the span element

I have been experimenting with the following jsfiddle and attempted various methods suggested in this Stack Overflow thread, but I am struggling to remove the focus from the "feedback" span after clicking on the cancel button in jQuery confirm dialog. Her ...

Toggle between list elements using the inner text of the elements with jQuery

My issue lies in figuring out why my filter function isn't properly working for toggling li elements. JavaScript: $("#searchbox1").on("keyup", function() { var value = $(this).val().toLowerCase(); $("#menulist li") ...

Utilizing CSS in JS for nested hover styles with Material UI: a step-by-step guide

I am currently utilizing Material UI and in the process of converting regular CSS classes into a JavaScript file. .nav { list-style-type: none; margin: 0; padding: 0; overflow: hidden; } .navItem { float: left; flex: 1; } .navLin ...

How can I toggle mat-table columns visibility in Angular?

I have a function in place that successfully removes columns from a mat-table. However, I am facing an issue when trying to add a column back into the table as the column index is not retained. Is there any way to maintain the column order when re-adding c ...

Issues with PHP and HTML form functionality?

I am currently working on a form that collects the user's name (input) and IP address (hidden input), and then saves this information to a text file. However, I am facing an issue where the IP address is not displayed on the page for the user to see, ...

Having trouble aligning a div vertically inside another div?

I am struggling to vertically align a div within another div. I have experimented with vertical-align, position: relative; top: 50%, and margin: auto; without success. Take a look at the code below: .main { font-family: "adobe-garamond-pro"; pad ...

Jquery event handlers are not functioning properly on dynamically added iframes with constantly changing content

I have added a dynamic iframe to the document using jQuery on document ready function. $( document ).ready(function() { $("body").append(renderIframe()); });} ` The iframe is rendered through this function function renderIframe(){ return [ ...

Developing a Java applet for the purpose of showcasing it in a web browser

As I embark on the journey of creating a basic Java applet to showcase my program's output in a web browser, I find myself facing unfamiliar territory. To gain a grasp on how applets function, I decided to follow a tutorial and create a simple "Hello ...

The silent button malfunctioning - Ionic

Within the html file: <video preload="metadata" muted="true" controls playsinline webkit-playsinline loop> Despite the "muted" tag, the video is playing with sound in both the browser and on the device. After referencing the video and setting the ...

Enhancing jQuery functionality by including parent elements

Recently delving into the world of jQuery, I've encountered a challenge. I have a script that resizes each image within a specific div. Now, I'm looking to place that resized image inside a non-existent div (creating a parent div). How can I ach ...

Is there a way to align the image to the left within the div contained in my header section?

I am facing an issue with positioning the logo in the header section of my website. It appears correctly on the left side for tablet and mobile versions, but on desktop, it does not align to the corner as desired. I tried adding a right margin, but I belie ...

Modifying the state object in ReactJS: A step-by-step guide on updating values

Below my query and explanation, you will find all the code. I am currently attempting to update the state in a grandparent class. This is necessary due to file-related reasons, and I am using Material-UI for text boxes. Additionally, I am implementing Red ...

Issues with overlapping floating labels in Bootstrap 5

Is there a way to display longer text without it being cut off or truncated, especially in input fields where the full content is necessary for clarity? It can be frustrating when only part of the text is visible. This issue arises from the Bootstrap 5 e ...

What causes a button to move to a new line following a div element?

Why does a button move to a new line after a <div> element even though it's an inline element? If I try putting the button inside the <div>, it gets removed due to JQuery constantly updating the <div>. Is there any way to prevent the ...

Is the input text returning NULL on postback?

Could someone please explain why the id value of the checkbox 'userId' is coming back as null during the POST request? <input type='checkbox' onclick='$("#userId").val("@user.Id"); return true; '/> @using (Html.BeginFo ...