CSS posing a variety of issues: opacity affecting text elements as well as misplacement of divs

<!DOCTYPE html>
<html>
    <head>
        <title>Title</title>

        <meta http-equiv="content-type" content="text/html; charset=utf-8">

        <style type="text/css">
            body {
                background: #00BFFF;
                font-family: "Candara";
                src: url(data/candara.ttf);
            }

            #wrapper {
                margin: 0 auto;
                width: 800px;
                padding: 15px;
            }

            #wrapper:after {
                content: ".";
                display: block;
                clear: both; 
                height: 0;
                overflow: hidden;
            }
                #header {
                    display: block;
                    background-color: blue;
                }
                    #header .left {
                        display: inline-block;
                        padding: 15px 25px;
                        float: left;
                    }

                        #header .left h1{
                            display: inline-block;
                            font-weight: bold;
                        }

                    #header .right {
                        float: right;
                        display: inline-block;
                    }

                        #header .right span{
                            display: block;
                        }

                #page {
                    display: block;
                    float: left;
                }

                #page .box{
                    display: inline-block;
                    background: black;
                    float: left;
                }

                #header, .box {
                    background: blue;
                    opacity: 0.7;
                }
        </style>
    </head>
    <body>
        <div id="wrapper">
            <div id="header">
                <div class="left">
                    <h1>Title</h1>
                </div>

                <div class="right">
                    <span><b>needle:</b> <?php //echo $haystack; ?></span>
                    <span><b>needle:</b> <?php //echo $haystack; ?></span>
                    <span><b>Last update:</b> <?php //echo $lastupdate; ?></span>
                </div>
            </div>

            <div id="page">
                <div class="left box">
                    Heey mannn
                </div>
            </div>
        </div>
    </body>
</html>

This design is what I'm trying to achieve, but it's not working as intended. Instead, the output looks like this.

I'm unsure of what I'm doing wrong and would appreciate some assistance. The desired layout is depicted in the image provided. The red areas highlight the specific sections that need to be included. I have also created a jsfiddle with the code for reference. If anything is unclear, please leave a comment instead of simply downvoting, as it can be challenging to explain the issue...

Answer №1

To achieve a see-through background, opt for colors using the rgba or hsla properties.

For instance:

background-color: rgba(0, 0, 255, 0.7); /* Represents Blue color with an opacity of 0.7 */

Answer №2

Below is a code snippet that will help you replicate the design image you have. Note that this code has only been tested in Chrome and may not be the most efficient solution, but it should assist you in moving forward with your design.

<!DOCTYPE html>
<html>
<head>
    <title>Title</title>
    <meta http-equiv="content-type" content="text/html; charset=utf-8">

    <style type="text/css">
        * {
            margin: 0px;
            padding: 0px;
        }

        body {
            background: #00BFFF;
            font-family: "Candara";
            src: url(data/candara.ttf);
        }

        #wrapper {
            margin: 0 auto;
            width: 800px;
        }

        #header {
            width: 720px;
            height: 100px;
            margin-top: 20px;
            padding: 10px 40px;
            background: rgba(0, 0, 255, 0.7);
            -webkit-border-radius: 13px;
            border-radius: 13px;
        }

        .title_area {
            float: left;
            width: 300px;
            margin-top: 12px;
            padding: 25px 25px;
            background: #f00;
            -webkit-border-radius: 13px;
            border-radius: 13px;
        }

        #header .info_area {
            float: right;
            width: 200px;
            height: 60px;
            margin-top: 30px;
            padding: 5px;
            background: #f00;
            -webkit-border-radius: 13px;
            border-radius: 13px;
        }

        #page {
            clear: both;
            margin: 20px 0px;
        }

        .content {
            float: left;
            width: 380px;
            height: 500px;
            padding: 20px;
            background: rgba(0, 0, 255, 0.7);
            -webkit-border-radius: 13px;
            border-radius: 13px;
        }

        .up_right {
            float: left;
            width: 320px;
            height: 240px;
            margin-left: 20px;
            margin-bottom: 20px;
            padding: 20px;
            background: rgba(0, 0, 255, 0.7);
            -webkit-border-radius: 11px;
            border-radius: 11px;
        }

        .down_right {
            float: left;
            width: 320px;
            height: 200px;
            margin-left: 20px;
            padding: 20px;
            background: rgba(0, 0, 255, 0.7);
            -webkit-border-radius: 11px;
            border-radius: 11px;
        }

        .close {
        clear: both;
        }
    </style>
</head>

<body>
    <div id="wrapper">
        <div id="header">
            <div class="title_area">
                <h1>Title</h1>
            </div>

            <div class="info_area">
                <div><b>needle:</b> <?php //echo $haystack; ?></div>
                <div><b>needle:</b> <?php //echo $haystack; ?></div>
                <div><b>Last update:</b> <?php //echo $lastupdate; ?></div>
            </div>
        </div>

        <div id="page">
            <div class="content">
                Heey mannn
            </div>

            <div class="up_right">
                Hou hou
            </div>

            <div class="down_right">
                Yeah
            </div>
            <div class="close"></div>
        </div>
    </div>
</body>
</html>

Answer №3

Using rgba is a great option, however there may also be cross-browser compatibility issues

Instead of simply using opacity: 0.7, you can try the following:

opacity: 0.7;
-moz-opacity: 0.7;
filter:progid:DXImageTransform.Microsoft.Alpha(opacity=0.7);

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

css clip-path hover effect restricted to specific shape

In the codepen I created, there are two greyscaled shapes. Currently, it's only possible to hover over one of them, as the original size is a box that overlaps both images. Is there a way to detect the shape being hovered over? Z-index hasn't pro ...

Revise the content of HTML5 page before displaying

Recently, I created a simple HTML5 page that requires the ability to support multiple languages. To accomplish this, I have set up the language control by loading a JSON file into memory when the page loads (in the HEAD section) and then using a jQuery com ...

Tips on removing pesky favicons

Not too long ago, I purchased a domain and configured it with Wordpress. Eventually, I decided to switch to a static landing page so I uninstalled Wordpress. But now there's an unfamiliar favicon that has appeared on my site. Even after deleting all ...

How can I turn off autocomplete in MUI textfields?

Currently, I am working with the latest version of mui. Within my user contact info form, there is a zip code field that I do not want to be auto completed if the value is null. However, despite my efforts, it continues to autocomplete with the email saved ...

Update the content of an HTML element without having direct access to the HTML code

I am currently in the process of creating a website using a website builder, and I am interested in customizing the default message that is displayed when a required field in the website form is left empty. The form in question is an integral part of the w ...

Incorporating a recurring image beneath a navigation menu

I'm attempting to recreate a header that has a similar appearance to the following: https://i.stack.imgur.com/uVXs3.png However, I am facing challenges in generating the repeating diamond design beneath the black bar. The diamond pattern resembles t ...

Tips for retrieving the option text value following an onchange event in AngularJS

Whenever I change the selection in my dropdown menu for 'Cities', the alert is displaying the value of the previous selection instead of the current one. For example, if I select a state and then switch to Cities, the alert shows the text related ...

Arrange two divs on either side of the center div when on a smaller screen

Looking for a straightforward approach to achieve this. Imagine it as follows: [A][__B_][A] to [A][A] [__B_] I hope that explanation is clear, but I'm happy to provide more details if necessary. Thank you in advance! ...

Looking for the location of a matching brace in a dataset?

As a newbie in the world of coding, I have embarked on learning about NodeJs file system module. Currently, my focus is on handling a large data file stored as a string. The challenge that I am facing is with locating the matching close brace and its pos ...

Arrangement of elements across rows and columns in a grid pattern

Is it possible to span a column that is equivalent to two columns in the first row and then have one column each for the second row, as shown in the screenshot? (There are two columns in the second row in this case) CSS main section { display: grid; ...

Tips for invoking a controller method in HTML code

Hello, I am completely new to AngularJS, HTML, JavaScript, and CSS. Please keep your explanations simple for beginners like me. I'm facing an issue where the function "updateFilterTerm" is not being called, causing the variable "filterTerm" to remain ...

"Hey, do you need a see-through background for your

Currently, I am implementing the JS library found at . Unfortunately, I am struggling to make the background transparent or any other color. It appears that the issue lies in the fact that the tab styles are being overridden by the JS library whenever the ...

Having issues with custom directives not functioning properly within AngularJS' RouteProvider

Currently, I'm in the process of learning AngularJS and specifically focusing on the route provider feature. I have successfully built a few pages that functioned well independently. Now, my aim is to implement the route provider into my project. In m ...

"Position the label on the left and input on the right for

Having trouble with label and input alignment - I've attempted: <div class="form-group"> <label class="control-label" for="" style="float: left;font-size: 20px;padding-right: 10px;">ID : </label> <input style= ...

Is there a way to switch out the WordPress page title for an image instead?

I am trying to change up the appearance of my WordPress site by replacing the text on page titles with images. Working on a child theme locally, I need to customize each page individually as they will have different images. The current state is as follows ...

Blueprint adjusts the height of the menu

After rendering the following code, the menu appears as a table with the ID topMainMenu and a height of 51. However, upon removing the Blueprint stylesheet, the height of topMainMenu reduces to 20, which I believe is the minimum height. <head runat="se ...

Is anyone interested in incorporating Bootstrap 4.1.2 into their project and utilizing the npm package manager for easy integration?

I am trying to integrate Bootstrap 4.1.2 into my project using npm as a package manager. Can someone assist with this? ** note: I prefer to have Bootstrap locally rather than using BootstrapCDN as shown below: <link rel="stylesheet" href="//maxcdn.boo ...

How to switch around div elements using CSS

There are two unordered list items in a container div and one swap button. When the swap button is clicked, the order of items needs to change. This functionality can be achieved using the following swap function. var ints = [ "1", "2", "3", "4" ], ...

Tips for achieving a design aesthetic similar to that of the JQuery UI website

On my website, I am using jQuery UI along with the "Smooth Default" CSS theme. However, I have noticed that everything appears larger compared to the jQuery UI website itself. For instance, when looking at the buttons here: http://jqueryui.com/button/ The ...

Is there a way to toggle or collapse a table row with a unique identifier using Angular and Bootstrap?

Currently handling Angular and Bootstrap in my work, but facing challenges with table manipulation and collapsing rows. I fetch data from a database and showcase it in a dynamically generated table using *ngFor and two rows within an ng-container. My goal ...