Tips for creating dynamic horizontal card layouts!

Check out my code here

I've been struggling to create responsive horizontal cards that adjust properly on different screen sizes. Despite attempting to change the background image based on viewport size, I have not been successful.

HTML

<!DOCTYPE html>
<html lang="en">

<head>
    ...
    

CSS

.container-fluid {
    width: 78%;
    ...
}

...

@media (min-width:565px) and (max-width: 1386px) {
    .poolBackground {
        ...
    }
}

The techniques I've tried so far include:

  1. Experimenting with setting images in the HTML itself and using vw units for resizing. However, the inner content did not scale properly along with the image.

  2. Attempting to display one card per row on smaller screens and two cards per row on larger screens, similar to the layouts shown in the provided pictures, but facing difficulties in achieving this layout.

Answer №1

<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <meta http-equiv="X-UA-Compatible" content="ie=edge">
    <!-- Bootstrap CSS -->
    <link rel="stylesheet" href="https://stackpath.bootstrapcdn.com/bootstrap/4.4.1/css/bootstrap.min.css" integrity="sha384-Vkoo8x4CGsO3+Hhxv8T/Q5PaXtkKtu6ug5TOeNV6gBiFeWPGFN9MuhOf23Q9Ifjh"
        crossorigin="anonymous">
    <!-- Font Awesome -->
    <link rel="stylesheet" href="https://use.fontawesome.com/releases/v5.8.2/css/all.css">
    <!-- Material Design Bootstrap -->
    <link href="https://cdnjs.cloudflare.com/ajax/libs/mdbootstrap/4.15.0/css/mdb.min.css" rel="stylesheet">
    <!-- add icon link -->
    <link rel="icon" href="./img/icon1.icon" type="image/x-icon">
    <link rel="stylesheet" href="pool.css">
    <link rel="stylesheet" href="font.css">
    <!-- scrollReveal property -->
    <script src="https://unpkg.com/scrollreveal@4"></script>
    <script>
        window.sr = ScrollReveal({
            distance: '50px',                                               //for animation of page scroll
            duration: 1000,
            easing: 'ease',
            mobile: true,
            reset: true,
            viewFactor: 0.4,
        });
    </script>
    <title>Pool2 | PLAY4LUX</title>
</head>
<style>
    .container-fluid {
    width: 78%;
    margin: 0 auto;
}

.poolBackground {
    background-image: url("image/r/Group\ <a href="/cdn-cgi/l/email-protection" class="__cf_email__" data-cfemail="a89ce89ad086d8c6cf">[email protected]</a>");
    background-position: center;
    background-size: cover;
    background-repeat: no-repeat;
    max-width: 565px;
    width: 100%;
    min-height: 288px;
    position: relative;
}

.poolImageContainer {
    background-image: url(imgi1.jpg);
    background-position: center;
    background-size: cover;
    background-repeat: no-repeat;
    max-width: 204px;
    width: 100%;
    min-height: 264px;
    /*position: absolute;*/
    top: 11px;
    left: 30px;
    box-shadow: 3px 5px 18px 0px #08061a;
    border-width: 4px;
    border-style: solid;
    border-image: linear-gradient(45deg, #8e602c, #b98b43, #f8ed8d, #b98b43, #8e602c) 1 1 1 1;
}

.poolRightContentContainer {
    /*position: absolute;*/
    top: 38px;
    padding-left: 28px;
    width: 80%;
}

.productName {
    font-size: 20px;
    background: linear-gradient(45deg, #8e602c, #f8ed8d);
    background: -webkit-linear-gradient(90deg, #8e602c, #f8ed8d, #8e602c);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    filter: drop-shadow(2px 3px 3px #000);
    font-weight: 900;
    margin-bottom: .9rem;
}

.title {
    display: inline-block;
    font-size: 17px;
    font-weight: 600;
    background: -webkit-linear-gradient(90deg, #fff, #fff);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    font-weight: 600;
}

.data {
    font-size: 19px;
    background: -webkit-linear-gradient(90deg, #fff, #fff);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    font-weight: 600;
}

.focused {
    font-size: 20px;
    background: -webkit-linear-gradient(90deg, #f8ed8d, #f8ed8d);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    font-weight: 900;
}

.drawDate, .winningOdd, .actualPrice, .tokenPrice {
    background: -webkit-linear-gradient(90deg, #fff, #fff);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    filter: drop-shadow(2px 4px 3px #000);
    font-weight: 600;
    margin-bottom: .6rem;
}...

// The code continues with the rest of the unchanged content.

Few amendments.. but still i suggest to re-write the or i can write for you from scratch if u want.. cheers bro... Happy to Help...

Answer №2

Instead of solely adjusting the image, have you considered manipulating the div container? By making the size of the container div responsive to the viewport, you can ensure that the image adjusts accordingly. Your image CSS may resemble the following:

img { 
max-width: 100%; 
height: auto; 
}

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

When developing a website in Sitecore 8, the link consistently opens in a new window rather than a new tab, even after including the target="_blank" attribute

When using Sitecore-8 CMS, external links are set to open in a new window instead of a new tab in Internet Explorer 10 and IE 9, even when target="_blank" is included in the href tag. We are seeking a solution to address this issue. Any assistance would b ...

The innovative grid system of Bootstrap 4 stands out for

I'm curious to learn more about the col-xs grid system in Bootstrap 4. Is Bootstrap 4 still considered an alpha version? I'm considering using Bootstrap 4 for my large project - will future updates cause any issues? ...

Error: controller undefined

As I delve into a Coursera course on AngularJS, I've encountered a perplexing issue with a controller. The console is indicating that it is not defined. Upon running it through the https://validator.w3.org/, a recurring error message mentioning that ...

`There is a delay in rendering the background image on Chrome`

Once I apply a class to my button element using JavaScript, the background image (.gif) that is supposed to display afterwards takes an unusually long time to render. The button serves as a form submission. Upon being clicked, a class of "clicked" is dyna ...

Differences between using CSS custom properties in the :root selector versus the body/html tags

Why would you choose to define global CSS custom properties in the :root element rather than in the body or html tags? How might this decision impact the effects or performance of the page? ...

Creating a seamless vertical navigation that connects the top banner with the bottom footer section

Having some difficulties with my current assignment. Any assistance would be greatly appreciated, whether it's a minor error I've overlooked or if I'm completely off-base with my code. The main challenges I'm facing involve getting my ...

What is the best way to add a 5px gap between elements?

I need to create spacing between elements in two grids. The spacing should be 5px horizontally. I tried using spacing={5} but it didn't work. <Grid container direction={'row'} spacing={5}> <Grid item xs={12}> <Form ...

Tips for resolving Layout Shift issues in responsive images utilizing the picture & source HTML tags

One issue I encountered with the <source> element is that even when specifying the width and height attributes for both the <source> and image fallback, there is still significant layout shift. This could be due to using images with varying dim ...

Challenges arise with the height settings of ui-grid

Currently, I am facing an issue with using height: auto on an angularJS ui-grid. The problem arises from an inline style that specifies a fixed height on the div to which the ui-grid attribute is added. Additionally, the function getViewPortStyle() dynamic ...

What is the process for aligning text with the margin on the left side

Inside a span block, there is an icon: <span><i></i>Text</span> The CSS for the icon is as follows: i { display: inline-block; width: 20px; height: 20px; } When the text inside the span is long, it wraps to the next lin ...

Still Facing the 'appendChild' Error Even After Defining it

Looking for assistance in creating new elements to display information on a Discord bot list I'm currently developing. var btn = document.createElement("BUTTON"); btn.innerHTML = "Try It"; document.body.appendChild(btn); ...

Creating personalized buttons with Bootstrap

I'm looking to create custom buttons using Bootstrap. The "Get Quote" button should have a magnifying glass symbol on its left, and the "Clear" button should have a symbol on its left as well, like shown in the image below. Additionally, I want to cha ...

Creating a webpage header with Javascript to mimic an existing design

I am in the process of building a website with 5 different pages, but I want the header to remain consistent across all pages. To achieve this, I plan to use an external JavaScript file (.js). The header includes the website name (displayed as an image) an ...

Using Twitter Bootstrap classes and spans within a control-group element

I'm working on creating a user-friendly interface that includes a group of checkboxes displayed as buttons. My goal is to organize these buttons into groups with a maximum of 3 buttons per row. <div class="container"> <div class="control-g ...

The group management options are mysteriously missing from Django's admin page

After deploying a Django web app, I encountered issues accessing the admin page. I expected to see the interface for adding or removing users from a specific group, but it was not displaying as expected. https://i.sstatic.net/5bfUy.png Upon inspecting th ...

What is the best way to synchronize the scale of images with the tempo of a song?

I just started learning CSS, JS, and HTML and I have a question about scaling an image based on a song. Despite searching through YouTube and various forums, I still haven't found a solution. Any help would be greatly appreciated :) Here is the HTML ...

Managing state changes with a slider in ReactJS

I am currently working with the Foundation slider found at this link: click for doc. To access the slider's current value, they recommend using a hidden input like this: <div class="slider" data-slider data-initial-start="50" data-end="200"> & ...

Jquery menu block shift

I am looking to implement a timer for the submenu within my menu. The idea is to show the submenu for 3 seconds after a mouse-over event. I have already set up a function to display and hide the submenu, but I am facing an issue where the submenu shifts to ...

Adjust the hover link color of the Bootstrap 4 navbar

Seeking tips on how to change link color when hovering over it. Appreciate any advice! HTML: <nav> <a class="underline" href="welcome.html">./home </a> <a class="underline" href="about.html" ...

The IDs and classes of HTML elements

I have two different implementations of a livechat script. On my sandbox site, the livechat is fixed to the bottom right of the page and scrolls with the window. However, on my live site (where this specific code comes from), it is attached to the footer. ...