Adding a shadow effect to a parent div: How can it be done?

Currently, I am at this stage: https://codepen.io/YellaChevy/pen/odYxrg

Sorry for my amateur markup skills as I am new to this. My main goal is to apply one box-shadow property to both "dogBlock" and "infoBlock". I believe it has something to do with the structure of my HTML but I'm not sure how to modify it to achieve a similar look to this:

I've observed on the pages.xyz website that they use multiple divs while having an overall box-shadow effect. Does that sound clear?

Thank you in advance!

<section>
<div class="container">

    <div class="dogBlock">
        <a href="#"><img src="Assets/image_1.jpg"></a>
    </div>

    <div class="dogBlock">
        <a href="#"><img src="Assets/image_2.jpg"></a>
    </div>

    <div class="dogBlock">
        <a href="#"><img src="Assets/image_3.jpg"></a>
    </div>

</div>
<div class="container">

    <div class="infoBlock">
        <h2>Sharpe</h2>
        <p>Lorem ipsum dolor sit amet, sir dolor em.</p>
        <a href="#">Meet Sharpe</a>
    </div>

    <div class="infoBlock">
        <h2>Bonnie, Mya + Roo</h2>
        <p>Lorem ipsum dolor sit amet, sir dolor em.</p>
        <a href="#">Meet the sisters</a>
    </div>

    <div class="infoBlock">
        <h2>Willow</h2>
        <p>Lorem ipsum dolor sit amet, sir dolor em.</p>
        <a href="#">Meet Willow</a>
    </div>

</div>

 .container {
max-width: 1200px;
overflow: hidden;
margin: 0 auto;}

.boxShadow {
box-shadow: 0 10px 6px -6px rgba(255, 255, 255, 0.2);}


.dogBlock {
width:33.333%;
float: left;
margin-top: 80px;}

.infoBlock {
color:#000;
width:33.333%;
float:left;
background-color:rgba(236,236,236,1.00);
padding: 20px;
margin-bottom: 280px;}

Answer №1

To achieve the desired result, each item's image and text need to be enclosed in separate div elements. Implement the following code:

<section>
    <div class="container">
        <div clss="boxwrap">
        
            <div class="dogBlock">
                <a href="#"><img src="Assets/image_1.jpg"></a>
                
                <div class="infoBlock">
                    <h2>Sharpe</h2>
                    <p>Lorem ipsum dolor sit amet, sir dolor em.</p>
                    <a href="#">Meet Sharpe</a>
                </div>
            </div>

            <div class="dogBlock">
                <a href="#"><img src="Assets/image_2.jpg"></a>
                
                <div class="infoBlock">
                    <h2>Bonnie, Mya + Roo</h2>
                    <p>Lorem ipsum dolor sit amet, sir dolor em.</p>
                    <a href="#">Meet the sisters</a>
                </div>
            </div>

            <div class="dogBlock">
                <a href="#"><img src="Assets/image_3.jpg"></a>
                
                <div class="infoBlock">
                    <h2>Willow</h2>
                    <p>Lorem ipsum dolor sit amet, sir dolor em.</p>
                    <a href="#">Meet Willow</a>
                </div>
            </div>
            
            <div class="clear"></div>
            
        </div>
    </div>
</section>

.container {
    max-width: 1200px;
    overflow: hidden;
    margin: 0 auto;
}
.boxwrap {
    margin-left: -15px;
    margin-right: -15px;
}

.dogBlock {
    width: calc(33.333% - 30px);
    float: left;
    margin-top: 80px;
    margin-left: 15px;
    margin-right: 15px;
    box-shadow: 0 5px 10px 1px rgba(0, 0, 0, 0.2);
    border-radius: 6px;
}

.infoBlock {
    color: #000;
    background-color: rgba(236, 236, 236, 1.00);
    padding: 20px;
    margin-bottom: 280px;
}

.clear {
    clear: both;
}

Answer №2

Implement it in this manner

.wrapper{
  max-width: 1000px;
  overflow: hidden;
  margin: 0 auto;
  -webkit-box-shadow: 3px 3px 4px 5px #dddddd; 
  -moz-box-shadow: 3px 3px 4px 5px #dddddd;  
  box-shadow: 3px 3px 4px 5px #dddddd; 
}

Test to verify its effectiveness.

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

How to retrieve the value from an editable td within a table using Jquery

I am working with a dynamic table that looks like this: <table> <tbody> <tr> <td>1</td> <td contenteditable='true'>Value1</td> </tr> <tr> ...

``There seems to be an issue with the alignment of items in the

I am fairly new to using css and bootstrap and I am currently working on integrating a carousel into my angular web app. I copied the code from the bootstrap site but I am facing challenges in aligning everything properly. Additionally, the image slides do ...

What is the process for incorporating icons and choices into the header bar?

Seeking advice on how to incorporate an icon into the right side alignment of a simple blank header on my webpage, similar to the image provided. I have searched through numerous threads on StackOverflow without finding a suitable solution. Could someone s ...

Is there a way to transfer a file in JavaScript from one location to another?

In my current project, I am utilizing HTML5 and JavaScript. One of the functionalities involves loading an image from a user-selected URL and then moving that image within a canvas. However, during this movement, the image tends to flicker which is not des ...

What is the best way to use html, css, jquery, and bootstrap to show or hide images without any extra space or alignment issues

I am looking to showcase 6 images on a page using the Bootstrap grid layout. The images should be displayed in two rows, with 3 images in each row. Additionally, I want to implement a filter functionality using Isotope, so users can click on a specific cat ...

The button on my page refuses to align in the center, and I'm at a loss as

Struggling to center a button within my div, despite having all other content centered. Here is my code: .middle { width: 100%; height: auto; text-align: center; position: relative; ...

Aligning an image vertically within a circular button using Bootstrap 4

Having trouble vertically aligning a plus image in the center of a circle button? I can't seem to make it work without adjusting margins. Is there a more Bootstrap-friendly way to achieve this? Below is the code snippet: .btn-circle { backgroun ...

Utilize jQuery to assign access keys to the numeric pad keys on the keyboard

I've been working on a Web App using HTML5 and jQuery 1.10, where I'm utilizing the accesskey attribute in inputs and links for enhanced navigation. Currently, my code looks like this: $("#linktabCost").attr("accesskey", "1"); $("#linkt ...

Guide to surrounding a div element with newly entered text to instantly display the corresponding CSS output

A unique text editing tool has been developed that showcases the CSS results in real time. For instance, when a user clicks Bold, the text becomes bold as the user types (displaying changes in real time). Similarly, there is a desire for a button that, upo ...

When the jQuery Cycle Slides are loaded on the page, they may appear

I have incorporated jQuery Cycle into many of my projects. This time, however, I am encountering a strange visual issue. Upon loading the page, all the slides appear stacked on top of each other. As the cycle progresses through each slide, the glitch event ...

Modify the appearance of HTML dialog box using CSS styling

Currently, I am working on a Java Spring project that includes a single CSS file consisting of around 1500 rows. Recently, I was tasked with adding a dialog box to one of the screens in the project. The issue I encountered is that the style of the dialog b ...

Preventing default behavior in a JQuery post request

Encountering an issue with jQuery functionality on a mobile device. function send() { $.post("scripts/post.php", { username: $("input[name=username]").val(), password: $("input[name=password]").val() }, function(data) { if ($(".data div" ...

Is it possible for webdriver to retrieve the URL of the style sheet being utilized by a specific element?

Currently, I am working on a test scenario where I need to confirm that altering an option in a dropdown menu modifies the styling of the page. I am curious if Webdriver has the ability to retrieve the URL of the CSS document from an element. This appear ...

Conceal Outcomes, W3Schools PHP Example AJAX Interactive Search

Currently, I am experimenting with the Ajax Live Search feature on the W3Schools website. It's functioning well, but I would like the results to hide when the user clicks away from them. I discovered a code snippet that achieves this, but I'm str ...

What is the best way to add animation to the hide/show function?

<div class="overlay"></div> CSS: .overlay::after { position: fixed; top: 0; left: 0; width: 100%; content: ""; z-index: -1; height: 100%; transit ...

The selection discrepancy is due to the misalignment between the cursor and white space in the CSS styling

Upon close inspection, I've discovered that a discrepancy exists between the selection on my webpage and the cursor position. After investigating further, I uncovered the following reasons: Presence of white-space between the start tag <p> and ...

Include the <script> tag in the HTML code for an iframe without running it

Currently, I am working on an HTML code that involves memory for an Iframe. Interestingly, whenever I use the append function, it not only executes the code but also carries out its intended task. html = $(parser.parseFromString($("#EHtml").val(), "text/h ...

Creating a Custom Checkbox with HTML and Label

How can I position the label on top of a checkbox? HTML: <input type='checkbox' name='thing' value='valuable' id="thing"/> <label for="thing">Description</label> CSS: input[type=checkbox] { display:n ...

Using Twitter Bootstrap to set a minimum number of lines for thumbnail captions

I currently have a carousel on my website created using Bootstrap that displays 4 columns of thumbnails. You can view the carousel here. When navigating to the third page of the carousel, you will notice that the container increases in height to accommodat ...

What could be preventing the justify-content:space-between; from working properly?

I'm experiencing an issue where the items are staying to the left instead of spreading out properly on my website. Additionally, when using Google Icons, they won't display unless I include the base tag in the head section since the domain name i ...