Before I can see the background image, I want the background color of my body to appear first

On the homepage, I want the background of the "main" section to be black. However, due to the image, the black background is not visible. This is the code I am using:

body {
    color: white;
    font-family: futura;
    background-color: black;
    font-size: 15px;
    max-width: 700px;
    margin-left: auto;
    margin-right: auto;
    background: url(Website_Bilder/background.png) 
    no-repeat center center fixed;
    -moz-background-size: cover;
    background-size: cover;
}

head {
    font-size: 30px;
    display: block;
    position:relative;
    background-position: center;
    background-size: cover;
    background-attachment: fixed;
    text-align: center; 
}

section {
    font-size: 15px solid #a0a0a0;
    border: 50px;
    padding: 0%;
    clear: ;
    margin: 1em auto;
}

ul {
    list-style-type: none;
    margin: 0;
    padding: 0;
    overflow: hidden;
    background-color: #333;
}

li {
    float: left;
}

li a {
    display: block;
    color: white;
    text-align: center;
    padding: 14px 16px;
    text-decoration: none;
}

/* link color */
li a:hover {
    background-color: #111;
}

img {
    width: 100%;
    float: center;
    height: auto;
    max-width:100%;
    display: block;
    margin: 1em auto;

    left:0px;
    top:100px;
    z-index:-1; 
}

p { 
    padding 10px 20px 10px 20px;
    margin 20px;
}

This is the current output:

I have taken a better screenshot and included more code.

Answer №1

It seems like you're looking to change the background of your red bordered area from an image to black in your CSS. You can achieve this by creating a new CSS class or ID for the surrounding HTML tag:

html, body {
height: 100%;
width: 100%;
}

body {
    color: white;
    font-family: futura;
    background-color: black;
    font-size: 15px;
    max-width: 700px;
    margin-left: auto;
    margin-right: auto;
    background: url(http://tub.tubgit.com/reimg/resize-img.php?src=http://photos.up-wallpaper.com/images251/jdicnfzws24.jpg&h=1080&w=1920) 
    no-repeat center center fixed;
    -moz-background-size: cover;
    background-size: cover;
}

div.redArea {
min-width: 70%;
height: 100%;
background-color: black;
text-align: center;
}
<!DOCTYPE html>
<html>
<head>
    <meta charset="UTF-8">
    <link href="style.css" type="text/css" rel="stylesheet">
</head>
<body>
<div class="redArea">
<p>this is a test</p>
</div>
</body>
</html>

To ensure the redArea class works properly, set its width as min-width due to the max-width constraint on the body selector being 700px.

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

Ensure that the absolutely positioned element disturbs the flow of scrollable text

My webpage has a text box that displays text content. The text box is set with a maximum height and overflow property of auto for scrollability. Now, I want to add a checkbox at the bottom right corner of this text box. To achieve this, I have positioned t ...

The function addClass() seems to be malfunctioning

I'm currently experimenting with creating a scrolling cursor effect on a string of text. The goal is to make it look like the text has been highlighted with a blinking cursor, similar to what you see in your browser's search bar. window.setInter ...

Implementing dynamic class changes with *ngIf within a child component

Apologies if this question has been addressed before, I found two similar answers here: Question related | Close Solution An Angular Material Sidenav component contains three components. The parent component (highlighted in red) includes tab-like but ...

Showcase the Uploaded Image Section within the Dropzone Display

https://i.sstatic.net/xzJWT.png Hello! I am currently working on implementing Dropzone.js to create a gallery. I've encountered a small issue where the default behavior of Dropzone displays a blank container area with a clickable effect to upload pho ...

Navigating through pages in React using Pagination Animations

Attempting to style an active button with a small transition when it receives that attribute has been a challenge. The same issue occurs with the paragraph rendered from the data file. function Pagination() { const [selected, setSelected] = useState(0) ...

Steps to Make a White Content Box on Top of an Image Background using HTML/CSS

I am currently struggling with overlaying a white box on top of my background image in order to have my text inside the box for a more visually appealing look. Despite trying to add CSS code like this: .white-box { position: absolute; background-c ...

Steps to conceal a div when a particular property is detected in one of its child elements (img)

On my website, I have a label and a checkbox. The checkbox in question is created by Salesforce (thus the dynamic appearance of the span id). This excerpt shows the code from my webpage: <div class="fds" id="checkinput"> <label>Additional Rev ...

How can jQuery determine the amount of line breaks within a div element?

My div wrap size is a percentage of the screen width, containing multiple .item divs that break into new lines as the window size decreases. I attempted to calculate the total number of boxes that could fit based on their widths compared to the container ...

When a single piece of content is exposed, it has the power to bring down all

I've been working with some code where clicking on a specific button toggles the visibility of certain contents. It's functionality is satisfactory, but I want to take it a step further. In addition to showing and hiding content, I also want to e ...

Using React-Bootstrap to create smaller user inputs

Is there a way to reduce the size of the Input element? By default, the syntax looks like this: <Input type='text' value='' placeholder='Enter Entity'/> Using bsSize='xsmall' does not work for making the inp ...

Difficulty with Bootstrap Carousel (image is displayed but fails to transition/change)

Although I don't have much experience in this, I've searched through various documentations and solutions that have helped others. Unfortunately, I haven't been able to fix my issue, so I decided to create my own post to seek assistance. &l ...

Thickness of Border in Bootstrap Cards

I've been attempting to include a thicker border around the entirety of my Bootstrap 4 card. Despite specifying a thicker border, nothing seems to change. Below is a snippet of the code I'm working with: <div class="container"> <di ...

"Exploring the Django framework's hidden pathways to

I am looking to include a CSS file in the header of my documents, but I have a couple of questions: 1. Where should I specify the path to the media, and should it be a relative or absolute path? In settings.py, I've attempted to set MEDIA_URL, but my ...

problem with navigation and right float orientation

I am trying to showcase two div elements inside a navigation bar on the right side of the screen. The issue I'm facing is that when I apply float: right to this particular div <div _ngcontent-c9="" class=" ng-clock docs-homepage-row menuSup"> in ...

"Maximizing Space: A Guide to Setting BootStrap Navbar on the Right Side of the Page with Dropdown Width

Take a look at the image below. There is a navbar toggle button on the upper right corner of the page. When I expand it, the dropdown items occupy the entire width of the page, causing an issue where clicking anywhere within the red box triggers the dropdo ...

The tab panels are failing to function properly due to the maxcdn CSS integration

I am struggling to make my basic JQuery code work, specifically to show and hide panels when a list item in the menu is clicked. The CSS I am using is from max cdn, so I'm unsure if I need to create my own CSS file for this. <!DOCTYPE html> ...

CSS - Divs failing to center using 'Auto: 0 Margin'

Attempting to design a menu bar using CSS, where the main buttons (blue divs) need to be centered within the navigation bar (orange divs) with equal spacing between each button. Despite trying margin: 0 auto, the alignment is not working as expected. Bel ...

Secret message concealed within the depths of my Bootstrap 5 Side Navbar

I have successfully created a side NavBar using Bootstrap 5, but I'm facing an issue where my text is getting hidden behind the navbar. Any suggestions on how I can resolve this? Below is the code for my side Navbar: const Navbar = ({ handleClick, is ...

Develop websites for specific iOs versions as well as various Android versions

When it comes to targeting specific versions of Internet Explorer, conditional comments or hacks can be used. Is there a similar method for targeting different versions of iOS? I'm facing an issue with my website functioning perfectly on iOS 4.2 and ...

Tips for updating the color of the mat-paginator's border at the bottom

Is there a way to change the border bottom color of my mat-paginator when an option is selected? It currently defaults to purple, but I would like to customize it. Any suggestions? Click here for an example of the current purple border on Mat-paginator. ...