Is there a way to ensure that the cards remain securely within the confines of the background image at

Struggling to keep the cards neatly contained within the background image regardless of screen size.

Here's my code snippet:

{% block content %}
    <style>
        .custom-skills-section {
            background: url('{{ background_image }}') center center / contain no-repeat;
            border-radius: 10px;
            padding: 20px;
            margin: 0 auto;
            width: 100%;
            max-width: 1600px;
            height: 1200px;
        }

        .custom-skill-card-shadow {
            height: 150px;
            display: flex;
            align-items: center;
            justify-content: center;
        }

        .custom-skill-card-content {
            border-radius: 8px;
            box-shadow: 0 4px 6px rgba(0, 0, 0, 0.1);
            background-color: #f0f4f8;
            display: flex;
            align-items: center;
            justify-content: center;
            width: 100%;
            height: 100%;
        }

        .custom-skill-title {
            font-size: 1em;
            font-weight: 600;
            color: #333;
            text-align: center;
            overflow: hidden;
            text-overflow: ellipsis;
            white-space: nowrap;
            width: 100%;
        }
    </style>

    <div class="d-flex justify-content-center align-items-center" style="min-height: 100vh;">
        <div class="custom-skills-section">
            <h2 class="text-center text-white py-4">My Skills</h2>
            <div class="container">
                <div class="row">
                    {% for skill in skills %}
                        <div class="col-lg-4 col-md-6 col-12 mb-4 custom-skill-card">
                            <div class="custom-skill-card-shadow">
                                <div class="custom-skill-card-content">
                                    <h4 class="custom-skill-title">{{ skill.name }}</h4>
                                </div>
                            </div>
                        </div>
                    {% endfor %}
                </div>
            </div>
        </div>
    </div>
{% endblock content %}

Greetings, I'm attempting to make the cards appear like they are pinned to a vintage note board but they always seem to spill out. On smaller screens, they protrude beyond the bounds of the background image both vertically and horizontally.

For reference, check out this image: https://i.sstatic.net/istlq2j8.png

Answer №1

Here is a helpful code snippet that can assist you. Adjust the CSS values to achieve your desired outcome.

<style>
.custom-skills-section {
    background: url('{{ background_image }}');
    height:100%;
    background-position:center;
    background-repeat:no-repeat;
    background-size:cover;
    margin:5%;
    overflow:scroll;
}

.custom-skills-section h2 {
    width:100%;
    text-align:center;
    color:white;
}

.custom-skill-card {
    width:33%;
}

.custom-skill-card-shadow {
    height: 150px;
    display: flex;
    align-items: center;
    justify-content: center;
    padding:1rem;
}

.custom-skill-card-content {
    border-radius: 8px;
    box-shadow: 0 4px 6px rgba(0, 0, 0, 0.1);
    background-color: #f0f4f8;
    display: flex;
    align-items: center;
    justify-content: center;
    width: 100%;
    height: 100%;
}

.custom-skill-title {
    font-size: 1em;
    font-weight: 600;
    color: #333;
    text-align: center;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    width: 100%;
}
.row {
    display:flex;
    flex-wrap:wrap;
}
</style>

<div class="d-flex justify-content-center align-items-center" style="height: 100%;">
    <div class="custom-skills-section">
        <div class="container">
            <h2>My Skills</h2>
            <div class="row">
            {% for skill in skills %}
                <div class="custom-skill-card">
                    <div class="custom-skill-card-shadow">
                        <div class="custom-skill-card-content">
                            <h4 class="custom-skill-title">{{ skill }}</h4>
                        </div>
                    </div>
                </div>
            {% endfor %}
        </div>
    </div>
</div>

Answer №2

Check out this CSS style recommendation:

.wrapper{
  max-width: 95%; /* ensures content stays within the box and is less than 100% */
}
.special-section {
 /* your current styles here */
 background-size: cover; 
}

Tip: When styling cards, opt for a grid display.

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

Is it recommended to keep static files in a dedicated S3 bucket while deploying using AWS Elastic Beanstalk?

I am currently running a Django app on AWS Elastic Beanstalk. The platform has created an S3 bucket to house the source code, versions, and other data. I have set up the S3 bucket to also store my static files. However, with each new code deployment, the ...

CSS styling for a background image in the header

Why isn't my background image showing up even though I've used a direct link to the image? What could be causing this issue? .header { background-image: url("https://www.africa.com/wp-content/uploads/2015/07/Kenya.jpg"); background-attac ...

Position the list-group to the right using a float

I am new to Bootstrap and I'm facing a challenge with arranging my list items. I have 15 items in total, and I want the last 7 items to be aligned on the right side (see the image for reference). Despite trying out various tutorials, I haven't be ...

Expanding Div Heights that Adjust to the Browser's Width

Looking to set up a responsive height for a div, almost there but facing some distortion when resizing the browser. Here is the fiddle file for reference: https://jsfiddle.net/td5n8ky9/10/ The issue lies in the bottom 2 divs - aiming for a grey bar the wi ...

Using jQuery to update the CSS class for all li icons except for the one that is currently selected

Utilizing Font Awesome Icons within the li elements of a ul Challenge When a user clicks on the user icon, the color changes from black to yellow. If the user clicks on another icon, that one also turns yellow. Is there a way to remove the existing yell ...

Tips for achieving a repeating transparent background image

I am trying to achieve a similar effect as shown in this example: http://jsfiddle.net/abalter/k8G3C/ The background image I'm using is transparent with the logo and text overlaying it. My issue arises when I set the background image to repeat-y. It ...

Tips for establishing breakpoints within Material UI grid for achieving responsiveness

I am currently utilizing Material ui's Grid component to organize my user interface elements. Here is the code snippet: <Grid container spacing={3}> <Grid container item xs={12} sm={12} md={12} style={{ marginTop: '-1.5%', marginRi ...

The code is triggering IE 8 to switch to compatibility mode resembling IE7

I have created a custom javascript function that generates a pop-up, and I am invoking this function in my code. However, every time I click the button, the browser switches to IE 7 compatibility mode and the pop-up appears behind the button. Below is my ...

Tips for transforming an SQL Server query into JSON format

I need to construct a table in a view utilizing the output of this particular SQL Query SELECT f.empresaid, e.fantasia AS Company, f.filialid, f.fantasia AS Branch, u.consultorid ...

Centering an image vertically in a fluid navigation bar

I'm currently working on creating a fluid navigation bar in Dreamweaver that adjusts the size of the logo when changing the viewport. Everything looks great, except for one issue - the logo image doesn't stay vertically centered when it gets smal ...

Unable to properly configure nginx rewrite to redirect from https to http in the server configuration

In order to manage heavy loads and enhance security within our application, we have implemented an Elastic Load Balancer from Amazon with SSL configuration. However, we are currently facing an issue with the redirection from http to https in the nginx conf ...

Follow us text placed in front of social sprite images all aligned on the same line

Is there a way to align the Follow Us text with sprite images? Check out this jsfiddle link for more details! <ul class="social_Emp">&nbsp;&nbsp;&nbsp;Follow us: <li class="Emp_twitter"><a href="{if $userInfo.TwitterPage} {$u ...

What is the best way to utilize the bootstrap grid system for smaller screens while incorporating a table?

I have a PHP generated table that retrieves data and dynamically displays it in a table. It is crucial to ensure that the table data adjusts according to the screen size. Below is the code snippet: echo "<div class='container'><div cla ...

What is the procedure for incorporating custom fonts from Google Fonts into Tailwind CSS?

https://i.sstatic.net/99gpe.pngI tried following the steps from a YouTube tutorial, but I am unable to apply the font family "nunito." I inserted the @import code into the CSS file located in the "src" folder and executed "npm run (script name)" in the t ...

Button interface in Angular

I am facing an issue with a div containing several buttons. Currently, they appear in a single column as illustrated in the image. I want to display them in rows, with 20 buttons per row out of the total 1000 buttons. How can I achieve this layout in Angul ...

Experiencing issues on Chrome while switching stylesheets; any tips on avoiding this glitch?

I am currently working on designing a webpage and running into some issues with Chrome when changing stylesheets for light and dark themes. Initially, I have included this <link>: <link rel="stylesheet" href="/css/dark.css" id="theme"> To sw ...

Implementing a horizontal scroll bar for mobile view using this code tutorial

Can someone provide guidance on how to implement a horizontal scrollbar for mobile view with the following code? <ul class="nav nav-tabs nav-justified" id="menutabs" style="width: 100%;"> <li class="nav-item ...

Could it be questionable XHTML originating from a conventional Haskell library?

Currently, I am working on resolving an issue with a program that generates XHTML in Haskell from UTF-8 text. The program is supposed to turn strings of text into valid XHTML entities, but it seems to be failing in doing so. I have imported Text.XHtml.Tran ...

Utilizing Jquery to toggle collapsed divs with a click event

Here is how my HTML appears: <h3><a href="#" title="story title">Story Title</a> <img class="expandstory" src="/images/plus.png" /></h3> <div class="description">Short description about the story</div> <h3 ...

Create CSS styles that are responsive to different screen sizes and

What is the best approach to ensure that these styles are responsive on any mobile device? nav ul ul { display: none; } nav ul li:hover > ul { display: block; } nav ul { background: #0066cc; background: linear-gradient(top, #0066cc 0%, #bbbbbb 10 ...