What is the best way to position text on top of a deck of cards?

looking for this

current status

this is my code:

<div class="card-deck test">
    <div class="card-group mx-auto test2">
        <div class="d-flex align-items-start overviewHeader">
            <h2>Overview</h2>
        </div>
        <div class="card overviewCard text-center">
            <div class="card-body align-items-center d-flex">
                <div>
                <!-- Content here -->
                </div>
            </div>
        </div>
        <!-- More cards here -->
    </div>
</div>

The CSS classes test, test2 are used to illustrate borders, the overviewHeader class styles the header, and the overviewCard class styles the card.
How can I position the header above and at the start of the card deck, similar to the first image provided?

Thank you in advance.

Answer №1

The flexbox property

<div class="d-flex align-items-start overviewHeader">
from bootstrap is wrapping the heading <h2>Überblick</h2>.

This is causing it to display inline.

To fix this, remove <h2>Überblick</h2> from those divs and place it at the top instead.

Answer №2

To achieve the desired layout, consider using flex-box.

  1. Start by creating a parent div with a height and width set to 100%.
  2. Add display: flex and justify-content: center; to align the content in the center.
  3. Next, create another div to contain the cards and adjust its width to less than 100%. Apply display:flex and justify-content: space-between. This will evenly distribute the cards with equal spacing. Refer to this link for more information.
  4. Insert div elements inside the parent divs. Style the cards with properties like max-width, height, and a subtle box-shadow. Customize the colors based on your preference. You can view an example of this design here.

The code snippet below demonstrates a responsive and scaled-down version of the layout:

body,
html {
  height: 300px;
}

.card-deck {
  height: 100%;
  width: 100%;
  display: flex;
  background: #ecf0f1;
  justify-content: center
}

.card-group {
  width: 70%;
  display: flex;
  align-items: center;
  justify-content: space-between;
  background: #ecf0f1;
}

.notification {
  width: 40px;
  height: 40px;
  border-radius: 30px;
  background: #3498db;
  position: absolute;
  top: -15px;
  left: -10px;
}

.overviewHeader {
  max-width: 20%;
  max-height: 50%;
  padding: 20px;
  position: relative;
  background: #fff;
  box-sizing: border-box;
  -webkit-box-sizing: border-box;
  -webkit-box-shadow: 17px 6px 29px 0px rgba(214, 214, 214, 1);
  -moz-box-shadow: 17px 6px 29px 0px rgba(214, 214, 214, 1);
  box-shadow: 17px 6px 29px 0px rgba(214, 214, 214, 1);
}

.overviewHeader h2 {
font-size:15px;
  text-align: center;
}

.text-center {
  width: 100%;
  text-align: center;
}

.some-image {
  width: 40px;
  height: 40px;
  border-radius: 30px;
  background: #bdc3c7;
  display: block;
  margin: 0px auto;
}
<div class="card-deck test">
  <div class="card-group mx-auto test2">
    <div class="d-flex align-items-start overviewHeader">
      <div class="notification"></div>
      <div class="some-image">
      </div>
      <h2>Overview</h2>

      <div class="card overviewCard text-center">
        <div class="card-body align-items-center d-flex">
          <div>
            Some Content;
          </div>
        </div>
      </div>
    </div>
    <div class="d-flex align-items-start overviewHeader">
      <div class="some-image">
      </div>
      <h2>Overview</h2>

      <div class="card overviewCard text-center">
        <div class="card-body align-items-center d-flex">
          <div class="text-center">
            Some Content;
          </div>
        </div>
      </div>
    </div>
    <div class="d-flex align-items-start overviewHeader">
      <div class="some-image">
      </div>
      <h2>Overview</h2>

      <div class="card overviewCard text-center">
        <div class="card-body align-items-center d-flex">
          <div>
            Some Content;
          </div>
        </div>
      </div>
    </div>
    <div class="d-flex align-items-start overviewHeader">
      <div class="some-image">
      </div>
      <h2>Overview</h2>

      <div class="card overviewCard text-center">
        <div class="card-body align-items-center d-flex">
          <div>
            Some Content;
          </div>
        </div>
      </div>
    </div>
  </div>
</div>

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

Displaying specific data points

I am encountering an issue where I want to select multiple values and have each selected value displayed. However, when I make a selection, I only see one value from a single box. I do not wish to use append because it keeps adding onto the existing valu ...

Tips for making a screen adapt to different monitor resolutions

Hello there! I've been working on a login screen using bootstrap 4, but I'm facing an issue with the layout. My concern is about adjusting the page layout so that the background image does not get cut off or distorted. Take a look at the image ...

Gleaming R: Warning prompt or modal box input: invalid

In the process of developing a basic application, I am seeking to implement a pop-up notification for invalid inputs. By referencing the suggestion provided in #1656, I have come up with an example that introduces a visually appealing background color when ...

An unsolicited border encompassing an image that does not resemble a CSS border or outline within the realm of Bootstrap 4

Utilizing Bootstrap4 Cards with .PNG image sources has resulted in an unexpected border appearing. It's not a border or outline issue. https://i.sstatic.net/KHgnP.png Here is the HTML <div class="row"> <div class="col-md-3"> <d ...

An error occurred: Reaching the maximum call stack size when utilizing the .map function in jQuery

Encountering a console error: Uncaught RangeError: Maximum call stack size exceeded This is the jQuery snippet causing trouble: $(document).on("change","select.task_activity", function(){ selected_activity = $("select.task_activity :selected").map(fu ...

What could be causing the constant issue of receiving an empty $_FILE when attempting to upload a file using ajax and php

I am currently utilizing ajax to send form data and upload files from the client to the server (php). An issue arises when attempting to access the file content on the server side - for reasons unclear, the $_FILES variable appears empty regardless of my ...

Using colored circles in ASP Dropdownlist ListItems (without jQuery): A step-by-step guide

Objective: To create a Dropdown list that displays a green circle if someone's Availability is True, and a red circle if someone's Availability is False. Note: The task needs to be accomplished without the use of jQuery, as it is restricted in t ...

Creating a border with tabs and a triangle using CSS

I'm having trouble getting my HTML/CSS tabs to look like the ones in the image. I've experimented with border-radius but haven't been able to achieve the desired result. Can anyone provide guidance on how to replicate these tabs using only ...

Converting Uniquely Designed Photoshop Shapes into HTML

I am working on a project to design an HTML page that features a profile picture with a heart frame. I have the PSD file with the heart frame included. The profile pictures will be rectangular in shape and should fit behind the heart frame without overlap ...

Another element concealing an element underneath

I am currently working on a website and could really use some assistance. Being new to web design, I find myself puzzled by this particular issue. The problem I'm facing is with a sawtooth pattern that should be displayed over a header, similar to the ...

Our search box is showing suggested results but we are unable to access the specific product sku. What steps can we take to resolve this issue?

/* This is a global settings template for CSS. The code includes various styling rules for elements such as article, nav, form, header, and footer among others. There seems to be an issue with the CSS that may be affecting the functionality of a drop-down ...

Ways to incorporate an image into an SVG file

This SVG image that I have created presents a unique design. <svg width="250px" height="250px" viewBox="0 0 250 250" version="1.1" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink"> <def> </def ...

Overlapping borders in Bootstrap 4 design

Working on my project with Bootstrap 4 and encountered a coding issue. Here is the code snippet: .form-info-tab { border: 1px solid #ccc; border-collapse: separate; border-spacing: 0px; padding:5px; text-align:center; } <link ...

Ensure that each class element contains a value before using jQuery to toggle the disabled class

I'm having trouble validating the values of the input elements in my form. I can't seem to figure out what I'm doing wrong. Can anyone help me out? Thank you. <div class="form--group"> <input class="thename" name="name[]" type= ...

Ways to resolve the issue of undefined $route.current in AngularJS

I have recently started using AngularJS and I am encountering an error "TypeError: $route.current is undefined". Please refer to the code snippet below: var sampleApp = angular.module('sampleApp', ['ngRoute']); sampleApp.config([&ap ...

Troubleshooting Challenges with JSON and jQuery Encoding

Having an issue with displaying data from a JSON file using jQuery: { "nombre": "Jesús Ramírez", "edad": "25 Años", "imagen":"file.jpg" } Here's my code: JAVASCRIPT $.getJSON(file.json, function(data) { var name= data.nombre; ...

What is the best way for Selenium in C# to identify and locate a specific span element by its value

I've been experimenting with different locators, but I'm struggling to find a straightforward solution for identifying the dynamic number within this span using C# Selenium. Initially, my focus is just on locating the span itself. <span inven ...

Discovering the amount of time a section of a webpage remains in view on a browser

I am looking for a way to track user engagement on my website that contains pages with extensive scrolling and numerous images. Each user who logs in sees a unique selection of images. My goal is to monitor how long users linger on each part of the page t ...

Tips for preventing the direct copying and pasting of JavaScript functions

Repeating the process of copying and pasting functions such as loadInitialValue(), loadInitialValue2(), loadInitialValue3(), is quite monotonous. This is the repetitive code snippet that I have been working on (when you click on "Mark as Read," the title o ...

`Videos on youtube with elements overlapping each other`

Having an issue with YouTube videos where other elements (LayerSlider) are overlapping on top of them. You can see the problem by clicking on this link () and trying to make the video fullscreen. I found a similar issue mentioned in the following link: Y ...