First attempt at creating a website and experimenting with adding a secondary color background using CSS

As I embark on the journey of launching my website, I am faced with the challenge of working with CSS for the first time. I decided to purchase a custom theme from themeforest to kickstart my project. My goal is to have two background colors on my website: a primary and a secondary color.

For reference, here is an example page: . What I am aiming to achieve is to maintain the orange background while introducing a white background behind the text to enhance readability and overall aesthetics.

Although my theme allows for custom CSS modifications (which I have used for changing the global font color), I am unsure about how to properly add the background effect. I have attempted the following code snippet:

#subbackground
{
width: 65%;
height: 100%;
background-color: #D9D9D9;
opacity: .2;
margin-left:-32.5%;
width:65%;
left:50%;
position:fixed;
z-index: 2;
color:#ffffff;
}

However, upon entering this custom CSS code, I did not observe any visible changes on the website.

I appreciate any assistance on this matter. Thank you in advance!

Answer №1

If you do not have a specific element with the identifier subbackground, then that code will not have any effect.

Considering the structure of your HTML page, it appears that:

.post-text {
  background-color: #FFF;
  opacity: 0.8;
}

could potentially be the solution you are seeking.

Answer №2

For your webpage, you can achieve the desired effect by including the following CSS code:

.post-text p
{
    background-color: #D9D9D9;
    opacity: .2;
}

This code will apply a background color and opacity to all paragraphs within elements that have the class 'post-text' (where your text is located). Your current approach is unnecessarily complex. Remember, simplicity is key :)

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

Toggle the visibility of table rows based on a specific class using a checkbox

I am currently working on a code that displays the results of a query in a table format. I would like to have the ability to click on certain elements to show or hide them. I know this can be achieved using toggle and CSS, but I keep encountering obstacles ...

Tips on maintaining and hiding the vertical scrollbar when a popup is open, alongside the navigation bar positioned at the top of the page

After reviewing this pen, my goal is to create a popup that maintains access to the navigation bar (hence avoiding Bootstrap's Modal). However, I am facing the challenge of keeping the scrollbar visible while preventing scrolling in the background whe ...

What caused the auto resize feature of the Automatic Image Montage jQuery plugin to malfunction?

Apologies in advance if my issue is a bit convoluted. I've integrated the Automatic Image Montage jQuery plugin into a page I'm currently working on. However, I seem to have disrupted the functionality that automatically resizes images when the w ...

Outer div encapsulating inner div within its boundaries

I am looking for a solution where the inner div stays fully contained within the outer div, without overflowing and overlapping with the padding of the outer div. Here is a code sample that demonstrates the issue .inner { /* Overflow */ overflow-wra ...

Is there a bug causing the Admin LTE content height issue? Looking for solutions to fix it

What's the reason behind the oversized footer? The footer appears normal when I resize or zoom the page, why is that? How can this be resolved? ...

CSS - Combining Selectors and Pseudo Classes to Boost Styling

When it comes to grouping selectors in CSS, there is an easy way to do it like this: .class1 #id1, .class2 #id2, .class3 #id3 { } Applying pseudo classes on these grouped selectors can be a bit repetitive. Is there a method to group multiple selectors a ...

Tips for creating CSS Grid elements that stay fixed to the viewport

I am attempting to achieve a 100vh viewport with multiple responsive overlays on top of it. I have managed to fix the header element on the viewport using position: sticky, but I am encountering issues with making the rest work in the same way. Additional ...

Navigate using React to a different HTML page based on certain conditions

After calling the fetch function, I am able to retrieve the correct token from the backend application. However, every time in this program, even if an incorrect token is retrieved, the program still navigates to StudentLobby (this should only happen when ...

Using CSS to break or wrap long words in text

I have a div that spans the width of the page. I'm looking to ensure that a very long word in this div breaks and wraps properly, so all the content stays within the screen width and doesn't overflow beyond 100%. Although I've attempted usi ...

Using React to organize content within a material-ui layout efficiently

Currently, I am developing a React page using material-ui integrated within Electron. The main requirement is to have an AppBar containing Toolbar and Drawer components. To achieve this, I have referred to the source code from https://material-ui.com/demo ...

The :before element is not displaying when using jQuery's slideToggle() method

When using only CSS, the .nav-main:before{} element is displayed, but with jQuery, it does not toggle that element and always keeps it hidden. Disclaimer: This issue has been observed on mobile devices (tested in Android Chrome). jQuery $('.menu-to ...

Customizing Image Layout with jQuery Masonry - Tips for Aligning Images

I've successfully created a jQuery masonry layout that showcases recent posts from various categories on the homepage. However, I'm facing two challenges and seeking help to address them: How do I remove the small white gaps beneath some ima ...

Position the typography component to the right side

Is there a way to align two typography components on the same line, with one aligned to the left and the other to the right? I'm currently using this code but the components are aligned next to each other on the left side. const customStyles = makeSt ...

"Enhance text formatting by making it stand out when hovered over

I am encountering an issue where the hover action for a specific letter begins before the mouse actually touches the text. In this case, I want the letter 'P' in 'Paul' to turn white when hovered over. The image illustrates the distanc ...

The Layout of Bootstrap4 Form is Displaying Incorrectly

I'm attempting to create a basic email form similar to the one shown in the Bootstrap 4 documentation. However, I am facing an issue where the formatting is not displaying correctly. Here is what the example should look like: https://i.sstatic.net/qx ...

Chakra UI Not Displaying Proper Responsiveness on the User Interface

I recently integrated Chakra UI for styling a project on Next.js, and while most components are functioning properly, I am facing challenges with implementing responsive layouts. The styles do not seem to adapt when the screen size is reduced. Here's ...

Remove CSS Styling from DataFrames in Pandas

My data frame consists of records that have this structure: Untitledp { margin-top: 0px;margin-bottom: 0px;line-height: 1.15; } body { font-family: 'Times New Roman';font-style: Normal;font-weight: normal;font-size: 13.3333333333333px; } .Normal ...

Creating a stationary menu on the header that overlaps both the header and content on mobile browsers

I'm currently in the process of developing a website, but I've hit a snag that I can't seem to figure out. You can view the website at . I'm focusing on mobile-first design, so for the best view, try shrinking the browser screen. When ...

CSS error with contrasting colors, the reason behind it is unknown

Here is the code snippet I am working on: I have set the background color to #f1f5ff and the font color to #181818. Despite thinking that the contrast is good, I am still encountering an error where the text is not visible. I have tried changing 'c ...

Widget remains static until job triggers data refresh, preventing CSS transition initialization

I am struggling with the html/coffee/scss aspects, although I'm comfortable with Ruby. On my website, I have implemented a hotlist widget sourced from this link: https://gist.github.com/andre-morassut/8705385. While it functions properly, I encounter ...