Increase the space around the text while zooming out to create a larger surrounding area

When zooming out, I would like the black area surrounding my text to expand instead of a white area appearing to the right. I attempted setting width:auto; on both div elements, but the black part disappeared completely. Below is my HTML code:

<!DOCTYPE html>
<html lang="">
<head>
    <meta charset="utf-8">
    <link rel="stylesheet" href="css/stylesheet.css">
    <title>lorem</title>
</head>
<body>
        <p style="white-space: nowrap">
<br><br><br><br><br><br><br><br><br><br><br><br><br><br>
<br>Lorem ipsum dolor sit amet, consectetur adipiscing elit. Vestibulum nec ipsum aliquam enim faucibus ultricies ut imperdiet ex. Phasellus ut quam sed velit ultrices tempor non eget urna. In vehicula sodales ante ut malesuada. In odio elit, congue a gravida id, semper non tellus.
<br><br><br><br><br><br><br><br><br><br><br><br><br><br>
        </p>
    <div class="div1">
    </div>
    <div class="div2">
    </div>
</body>
</html>

Below is the CSS section:

@font-face {
font-family: "Consolas";
src: url("Consolas.ttf");
}

*{
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}
main {
    position: relative;
}
 p{
     display: inline-block;
    font-size:15px;m
    font-family:"Consolas";
    margin:0 3px;
    width:900px;
    position:relative;

}
.div1{
    background-color:black;
    float:right;
    height:40000px;
    width:50px;
}
.div2{
    background-color:black;
    float:left;
    height:40000px;
    width:50px;
}

The issue can be better understood with these three images. A white space fills in as I zoom out on the text posted on my website rather than the black portion beside the text expanding. The red lines indicate where I want to see black instead of white...

Image without zoom Image at 90% zoom Image at 70% zoom

I'm new to this and received help from a friend with the code, so I might not be approaching it correctly. Thank you in advance :)

Answer №1

Are you referring to adjusting the browser zoom level?

    .zoom
{
    zoom: 150%;
    background-color: black;
    */ include your additional styles here*/

}

Answer №2

After making some adjustments to your HTML code, I utilized flexbox to create a layout that closely resembles what you were looking for (at least, I hope so):

.custom-design { 
  display: flex;
  height: 100vh;
  background: black; 
}
.custom-design p {
  padding-top: 50vh;
  background: white;
  min-width: 900px; 
  margin: 0;
  white-space: nowrap;
  overflow-x: auto;
  overflow-y: hidden;
}
.custom-design div {width: 50px; background: black;}
<div class="custom-design">
  <div class="section1"></div>
  <p>Lorem ipsum dolor sit amet, consectetur adipiscing elit. Vestibulum nec ipsum aliquam enim faucibus ultricies ut imperdiet ex. Phasellus ut quam sed velit ultrices tempor non eget urna. In vehicula sodales ante ut malesuada. In odio elit, congue a gravida id, semper non tellus.</p>
  <div class="section2"></div>
</div>

If you have any questions or need further clarification, please don't hesitate to reach out. Happy coding!

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

Bootstrap's hidden navigation bar feature

I noticed that my navbar changes from transparent to opaque when scrolling. I am trying to achieve a similar effect like the one in this example: https://i.sstatic.net/00uPM.png Initially, my navbar looks like this: https://i.sstatic.net/iMyYL.png As y ...

Using CSS background-image URL in .NET MVC tutorials

What is the correct way to route to an image in an MVC web application? MVC has default routes, meaning you can access the same page in multiple ways: 1. localhost 2. localhost/home/index However, you can also do it this way, changing the root directory. ...

Reducing the number of DOM manipulations for websites that heavily utilize jquery.append

Here's a snippet of my coding style for the website: !function(){ window.ResultsGrid = Class.extend(function(){ this.constructor = function($container, options){ this.items = []; this.$container = $($container); ...

Ensuring Smooth Alignment of CSS Divs

I am facing challenges with the compatibility of my CSS code for HTML checkboxes. In certain versions of Internet Explorer and when I insert the live HTML into my PowerPoint presentation, the center div overlaps with the left div causing the entire page to ...

What are some methods to design distinct angular ui bootstrap dialogs?

Is there a way to customize angular-ui bootstrap modal dialogs so that they have distinct colors and sizes from each other? I can style them globally for the site but not individually. I came across a similar question, but it only addresses changing all d ...

Transitioning from traditional desktop WPF Applications to HTML5-based solutions

Our small team within the department has been utilizing WPF for quite a few years now, consisting of just myself as the programmer and a designer. We primarily develop business applications for our company, such as shipment tracking tools and more. Lately ...

I recently aligned a component within a column of the Bootstrap grid using the <center> tag

Apologies for admitting this on Stackoverflow, but I'm struggling to center an element and the center tag seems to do the trick. My CSS skills are limited, so I'm reaching out to see if there's a better way to achieve this? <div class="c ...

putting a division element above a image carousel

Is there a way to overlay a div tag on top of a slideshow, similar to the one shown in this link? In the example provided, a div with the title "DISCOVER THE JOY OF COOKING" is positioned over a slideshow. Any tips on how I can achieve this effect? ...

The value binding for input elements in Angular 4 remains static and does not reflect changes in the UI

Struggling with binding input to a value in angular 4? Take for example [value]="inputFrom". Sometimes it updates when I change inputFrom, other times it doesn't. How can I ensure the input always changes whenever inputFrom changes, not sporadically? ...

The font style in React appears distinct from that of Bootstrap

I am looking to create a login page using both bootstrap and react. I found the perfect style on the official website. To implement this, I included all the necessary bootstrap and CSS files in my index.html file: <!DOCTYPE html> <html lang="en"& ...

The fixed navigation bar shows a flickering effect while scrolling at a slow pace

Currently facing a challenge with our sticky navigation. Noticing a flickering issue on the second navigation (sticky nav) when users scroll down slowly. The problem seems to be specific to Chrome and Edge, as it doesn't occur on Firefox, IE11, and S ...

Sending JSON data from the primary window to the secondary window in Electron - A step-by-step guide

I am currently working with a set of 3 files. index.html: ... <a href="#" onclick="fetch(function(data) {console.log(data); subWindow(data)})">subWindow</a> ... The fetch() function retrieves a callback in JSON format. subWindows.js: let m ...

Is it permissible to assign the same element as a child to multiple parent elements in jQuery?

Imagine you have the following HTML structure: <div id="first"></div> <div id="second"></div> Now, if you use JavaScript and JQuery to perform the following actions: var $child = $("<span id='child'>Hello</span ...

What is the best method to verify image dimensions and size for three distinct target platforms, all of which have different image dimensions but the same size, within

I'm currently working on a feature that involves an image uploader for various platforms, each with its own set of recommended image dimensions. For example: platform 1 - dimension 920 x 300, platform 2 - 210 x 200, and platform 3 - 790 x 270. When th ...

How can I retrieve HTML with JavaScript enabled?

Seeking to extract the HTML code from a webpage using PHP, I attempted the following: $url = 'http://en.wikipedia.org/wiki/New_York_City'; $html = file_get_html($url); However, an issue arose where Wikipedia failed to supply the <script> ...

Prevent CSS3 columns from reverting back to their original state after being rendered

Utilizing css3 columns, I have created a layout with an unordered list displayed in 3 columns. Each list item contains another list that can be toggled to show or hide by clicking on the title using jQuery. The structure of the html is as follows (with ex ...

Guide to inserting text into an html element upon clicking an ASP:Button

In my code, there is a DIV that holds some text. Accompanying the text is an asp:Button. When this button is clicked, I aim to access and save this particular text. Nonetheless, it seems that once the button is clicked, the content of the DIV resets - lik ...

HTML file unable to connect with CSS stylesheet

I'm facing an issue where my CSS stylesheet and HTML files aren't linking properly. Here is the code snippet from my HTML file: <head> <title>Website Sample</title> <meta charset="UTF-8"> <meta http-equiv= ...

JavaScript progress bar with extended duration, inspired by the success-oriented approach

Currently, I am in search of a unique solution or plugin that can replicate the same effect as Kickstarter's crowd fund long term progression bar. It seems like existing solutions only offer short term dynamic progress bars that indicate the percentag ...

Javascript functions fail to execute as intended

I have a project called calc, which includes various functions such as init. Within this project, there are three buttons that I am adding to the div using jquery. When a user clicks on any of these buttons, it should trigger the inputs function. Based on ...