Is there a way to eliminate the space between the gray background and the right edge of the browser window?

   

body{
    font-family:'Montserrat';
    
}

.content{
    background-color:#d9d9d9;
}



   

p.dates{
    display:inline-block;
    font-weight:800;
    margin-right:20px;
    width:120px;
    text-align:center;
    margin-top:0;
    margin-bottom:0;
    
}
p.content{
    display:inline-block;
    text-align:left;
    width:85%;
    height:50px;
    
    margin-top:0;
    margin-bottom:0;
       
}
   
    </div>
    <div class="timeline-content">
        <br>
        <hr>
        <p class="dates">28 June 1971</p>
        <p class="content">Elon Reeve Musk was born on June 28, 1971 in Pretoria, South Africa.</p><br><hr>
        
        <p class="dates">1988</p>
        <p class="content">Elon moved to Canada when he was 17 to attend Queen's University.</p><br><hr>

        <p class="dates">1990</p>
        <p class="content">Elon transferred to the University of Pennsylvania, where he received dual bachelor's degrees in Economics and Physics.</p><br><hr>
        <p class="dates">1995</p>
        <p class="content">He relocated to California to begin a Ph.D. in applied physics and material sciences at Stanford University but left after 2 days to pursue a business career.</p><br><hr>
    </div>

    </div>
</body>
</html>

The content at the bottom of the page with a gray background is what I am referring to.

I am designing this tribute webpage, but I am struggling to eliminate the gap between the gray background and the right side browser boundary in the section that displays details for each date/year.

Answer №1

If you want to achieve this without altering your HTML structure, you can utilize the calc() function in CSS within the .content class and set it as follows:

width: calc(100% - 144px);

Please note: While this method will work, the value of 144px is fixed due to the fixed width of date being 120px and additional properties like margin.

body {
  font-family: 'Montserrat';
}

.content {
  background-color: #d9d9d9;
}

p.dates {
  display: inline-block;
  font-weight: 800;
  margin-right: 20px;
  width: 120px;
  text-align: center;
  margin-top: 0;
  margin-bottom: 0;
}

p.content {
  display: inline-block;
  text-align: left;
  width: calc(100% - 144px);
  height: 50px;
  margin-top: 0;
  margin-bottom: 0;
}
</div>
<div class="timeline-content">
  <br>
  <hr>
  <p class="dates">28 June 1971</p>
  <p class="content">Elon Reeve Musk was born on June 28, 1971, in Pretoria, South Africa.</p><br>
  <hr>

  <p class="dates">1988</p>
  <p class="content">Elon moved to Canada at the age of 17 to attend Queen's University.</p><br>
  <hr>

  <p class="dates">1990</p>
  <p class="content">Elon transferred to the University of Pennsylvania, where he obtained dual bachelor's degrees in Economics and Physics.</p><br>
  <hr>
  <p class="dates">1995</p>
  <p class="content">He relocated to California to pursue a Ph.D. in applied physics and material sciences at Stanford University, but after two days, he decided to embark on a business career instead.</p><br>
  <hr>
</div>

</div>
</body>

</html>

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

Update the image and heading simultaneously when hovering over the parent div

I am looking to enhance the user experience on my website by changing the color of headings and images when a user hovers over a specific section. Currently, I have been able to achieve this effect individually for each element but not simultaneously. Any ...

Adding code containing various Google Maps elements in a fresh browser window using JavaScript

I've encountered an issue while trying to create a new page with a Google map and title based on the button clicked. Interestingly, when I copy/paste the HTML in the "newhtml" variable into an actual HTML file, it works perfectly fine. However, it doe ...

Tips for aligning text to match the starting point of other text

Currently, the text appears as follows: Lorem ipsum dolor sit amet consectetur adipiscing elit vitae orci elementum dictum I want it to look like this: Lorem ipsum dolor sit amet consectetur adipiscing elit vitae orci elementum dictum I ...

What could be causing the issue with the 100% height and 100% width not functioning properly on my ASPX page?

The CSS and HTML code work perfectly in an isolated test environment: body, html { height: 100%; min-height:600px; min-width:800px; overflow:hidden; margin:0;padding:0; } html {overflow:auto;} .fill {height:100%; width:100%; backgro ...

What is the process for creating a beveled edge on a block div?

I am working on an HTML document that includes a DIV tag with specific styling: <!DOCTYPE HTML> <html> <head> <meta charset="utf-8"> <title>DIV Tag</title> <style type="text/css"> ...

Designing the appearance of a button in a filefield xtype

I am currently working on a web application where users can upload photos using a fileField. I have been struggling to style the button for this feature, as my attempts so far have not been successful. Initially, I tried using the element inspector to iden ...

Enlarging and cutting video footage

I have developed an app that features a code enabling users to capture photos using their computer-connected camera. How it Works: A webcam is utilized to display a video element with the camera as its source: function onSuccess (stream) { this.video.s ...

Set a consistent pixel measurement for all images

I am working on a project where I have an image of a card that needs to be repeated 30 times. Each time the card is repeated, I want it to overlap with the previous card in a specific position, resembling a deck of cards. The issue I am facing is that whe ...

Adjustable block with excess content

Forgive me if this question seems basic, but I'm not very familiar with CSS. I have a table with two columns that need to be equally sized and responsive when the page is resized. The header isn't an issue since it only contains a few words in ...

svg xlink attribute not functioning properly when embedded as svg object within html

Within the SVG, I have multiple A elements linking to various pages. When the SVG is loaded into a browser as a standalone, the links function properly. However, when it is embedded as an object within an HTML page, the links do not work. It seems like th ...

How come my directive is being updated when there are changes in a different instance of the same directive?

For the purpose of enabling Angular binding to work, I developed a straightforward directive wrapper around the HTML file input. Below is the code for my directive: angular.module('myApp').directive('inputFile', InputFileDirective); f ...

Tips to position a div directly on top of table cells using absolute positioning

I have a div inside the second table cell that I want to position absolutely right outside the <td>. Currently, the issue is that the <td> elements below are overlapping the div. Eventually, each <td> will contain a div that appears on ro ...

Importing JSON Data into an HTML File

I need to load a JSON file containing HTML content into my main HTML file upon clicking a button. ABC.json includes: <li><img src="images/picture6.jpg" /></li> <li><img src="images/picture5.jpg" /></li> <li><i ...

Assess the equation twice using angular measurement

I am attempting to assess an expression that is originating from one component and being passed into another component. Here is the code snippet: Parent.component.ts parentData: any= { name: 'xyz', url: '/test?testid={{element["Te ...

The CSS child selector seems to be malfunctioning as it is affecting all descendants of the specified type

Struggling with creating a menu containing nested lists. Attempted using a child selector (#menu-novo li:hover > ul) to display only immediate descendants, but all are still showing. Any suggestions or solutions for this issue? #menu-novo-container { ...

What are the steps to execute a file on localhost using an HTML page?

Currently, I have an HTML file that leverages the Google Calendar API javascript to read the next event on my calendar. The functionality works flawlessly when manually inserting a specific URL in a browser address window, which triggers a GET request in a ...

Adding a dynamic form to each row in a table: A step-by-step guide

https://i.sstatic.net/HctnU.jpg Hey there! I'm facing a challenge with dynamically generated rows in a form. I want to send only the inputs from the selected row when a checkbox is clicked. Can you help me figure this out? I tried using let rowForm ...

Finding the Row Number of an HTML Table by Clicking on the Table - Utilizing JQuery

Seeking assistance to tackle this issue. I currently have an HTML table with a clickable event that triggers a dialog box. My goal is to also retrieve the index of the row that was clicked, but the current output is not what I anticipated. //script for the ...

Steps to Import an Image from a Subdirectory:

Currently, I am working on C# and HTML. While working on a view page, I encountered an issue when trying to load images from subfolders. When attempting to load an image from the immediate folder, it opens correctly. For example: <img data-u="image" s ...

Having trouble with the preview feature when resizing images

Before trying to implement the JSFiddle was working correctly: http://jsfiddle.net/qa9m7t33/ However, after attempting to implement it, I encountered some issues: http://jsfiddle.net/z1k538sm/ While trying to resize an image, I realized that this example ...