How come my blocks are spilling over into other blocks?

I have successfully created a webpage using Drupal 8 and Bootstrap, featuring a "Learn more" button to expand the details.

However, I am facing an issue where the information blocks overflow when collapsed. The gray line and label are spilling into the upper block.

Could someone please advise on how I can resolve this? Thank you in advance.

Here is an image showing the overflow of the gray line and label:

https://i.sstatic.net/1Hssn.jpg

When the information is expanded, everything looks good:

https://i.sstatic.net/KfrV3.png

Below is the TWIG code:

  <div class="card mb-5 p-0 overflow-hidden shadow rounded bg-white">
    {{ drupal_view('boutique_professionnel_page_diaporama', 'block_1') }}
    <div class="card-body pt-0">
      <div id="readmorecollapse">
        <div class="collapse" id="collapserm" aria-expanded="false">
          <div class="col-xs-12 col-sm-12 col-md-12 col-lg-12 p-0 border-bottom">
            <div class="mb-4">
              <div class="mr-4 float-left rounded-lg overflow-hidden">
                {{ store.field_professionnel_logo }}
              </div>
              <h1 class="mt-0">{{ store_entity.name.value }}</h1>
              {{ store.field_professionnel_description }}
            </div>
          </div>
          <div class="col-xs-12 col-sm-6 col-md-6 col-lg-6 bs-left pl-0 mt-3">
            <div class="mb-3">
              {{ drupal_entity('user', store_entity.uid.target_id, 'store_default') }}
            </div>
            <div class="mb-3">
              {{ store.field_professionnel_ets_id }}
            </div>
            <div class="mb-3">
              <a class="text-decoration-none text-primary" href="mailto:{{ store_entity.mail.value }}">{{ store.mail }}</a>
            </div>
            <div class="mb-3">
              <a class="text-decoration-none text-primary" href="tel:{{ store_entity.field_professionnel_telephone.value }}">{{ store.field_professionnel_telephone }}</a>
            </div>
          </div>
          <div class="col-xs-12 col-sm-6 col-md-6 col-lg-6 bs-right pr-0 mt-3">
            <div class="mb-3">
              <a class="text-decoration-none text-primary" href="geo:{{ store_entity.field_localisation.value }}">{{ store.address }}</a>
            </div>
            <div class="mb-3">
              {{ store.field_professionnel_accueil }}
            </div>
            <div class="mb-3">
              {{ store.field_professionnel_horaires }}
            </div>
          </div>
        </div>
        <div class="readmorebutton">
          <a role="button" class="collapsed btn btn-default btn-xs" data-toggle="collapse" href="#collapserm" aria-expanded="false" aria-controls="collapserm">
          </a>
        </div>
      </div>
    </div>
    <div class="card-footer d-flex flex-wrap justify-content-start pt-0">
      <div class="mt-3 mr-3">
        {{ store.flag_report_store }}
      </div>
      <div class="mt-3 mr-3">
        {{ store.flag_like_store }}
      </div>
      <div class="mt-3 mr-3">
        {{ drupal_block('shariff_block') }}
      </div>
    </div>
  </div>

And here is the CSS code:

#readmorecollapse div.collapse[aria-expanded="false"] {
    height: 100px !important;
    overflow: hidden;
    visibility: visible;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;  
}

#readmorecollapse div.collapsing[aria-expanded="false"] {
    height: 42px !important;
}

#readmorecollapse .readmorebutton a {
    width: 100%;
}

#readmorecollapse .readmorebutton .collapsed  {
    box-shadow: 0px -10px 25px 0px rgba(255, 255, 253, 0.8);
}

#readmorecollapse .readmorebutton a.collapsed:after  {
    content: 'Show all information';
}

#readmorecollapse .readmorebutton a:not(.collapsed):after {
    content: 'Hide';
}

Answer №1

In order to solve the issue, it is necessary to add overflow: hidden; to the first child element within div#collapserm. The required CSS code should look like this:

/* Removing the overflow */
#readmorecollapse div.collapse[aria-expanded="false"] {
    height: 100px !important;
    visibility: visible;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;  
}

/* Adding a new rule for the first child */
#readmorecollapse div.collapse[aria-expanded="false"] div:nth-child(1) {
    overflow: hidden;
}

#readmorecollapse div.collapsing[aria-expanded="false"] {
    height: 42px !important;
}

#readmorecollapse .readmorebutton a {
    width: 100%;
}

#readmorecollapse .readmorebutton .collapsed  {
    box-shadow: 0px -10px 25px 0px rgba(255, 255, 253, 0.8);
}

#readmorecollapse .readmorebutton a.collapsed:after  {
    content: 'Show all information';
}

#readmorecollapse .readmorebutton a:not(.collapsed):after {
    content: 'Hide';
}

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

What is the correct syntax for implementing scrollTop and transform CSS effects in jQuery?

I find myself in a bit of a quandary, as this question may seem rather simple but it's causing me some confusion. I'm trying to navigate the CSS transform syntax within a jQuery script that calculates window height. Here is the code in question: ...

In search of the HTML code for the forward button when extracting content from a webpage

While using Power Automate Desktop to scrape a webpage, I encountered an issue with clicking the next button. Even after copying the HTML code within the developer tools of the webpage, I found that both the previous and next buttons had the same path, mak ...

How to fetch select element within a table by using jQuery

I encountered a situation where I have a table element with a select element inside its td. The id of the table (in this example, it is "table1") could potentially change. So my query is, how can I retrieve the selected option using the table ID in JQuer ...

Tips for modifying the font style of a Bootstrap form input using a custom font

While developing my website using Bootstrap 4, I encountered an issue with the custom font (GeosansLight) I applied to the entire website through the body's CSS attribute. The problem arose when the default Bootstrap form inputs appeared too light to ...

What is the simplest way to shift an icon to the right in the header of an Expansion panel using Vuetify

After implementing the template from this example: https://vuetifyjs.com/en/components/expansion-panels/#usage I am facing an issue where the header icon is stuck to the title Even applying "float: right;" does not seem to resolve it Has anyone els ...

Include chosen select option in Jquery form submission

Facing some challenges with a section of my code. Essentially, new elements are dynamically added to the page using .html() and ajax response. You can see an example of the added elements in the code. Since the elements were inserted into the page using . ...

What are the steps to create a dynamic navigation menu in Angular 2?

I have successfully implemented this design using vanilla CSS and JS, but I am encountering challenges when trying to replicate it in Angular 2. Setting aside routing concerns, here is the current state of my component: navbar.component.ts import { Comp ...

Display a pleasant alert message when the file is not recognized as an image during the loading

Is there someone who can assist me? I have attempted multiple times but without success. How can I display a sweet alert when a file is selected that is not an image? <input type ="file" /> ...

Twig template delivers HTML entities

I am dealing with an issue related to the twig template. Instead of displaying HTML markup, it is showing raw HTML characters. <?php /* HomepageController.php */ namespace App\Controller; use Sensio\Bundle\FrameworkExtraBundle\Co ...

Updating a conditional statement in jQuery

Understanding jQuery has always been a challenge for me. I find myself spending hours reading documentation every time I try to implement it, only to achieve very little progress. Here's the code I'm currently working on with live-editing availab ...

Guidelines for Naming Data Attribute Values in JavaScript

When it comes to the Data Attribute Value, should one use hyphens or camelCase as a convention? Hyphen Example: <input type="text" name="some_input" data-target="to-grab-input-via-javascript"> Camel Case Example <input type="text" name="some_ ...

Creating consistent image sizes in Bootstrap

I'm currently using Bootstrap 4 to showcase multiple images on my website. I have attempted to apply the Grid system as per Bootstrap's guidelines, but the display of the images is not aesthetically pleasing due to their uneven sizes, which can b ...

Toggle the display of slide numbers in RMarkdown xaringan / reveal.js presentations

In preparation for a workshop, I am creating HTML slides using the xaringan package in R, which is based on remark.js. These slides are made with RMarkdown, and while this approach has been effective, I have encountered a need to disable slide numbers on s ...

To include a slash or not before the assets path in HTML - that is the question

Should the use of / in front of paths in HTML pages be considered a good practice? If using / for paths, is it necessary to configure a <base url=""> in the page? An issue arises with a generated CSS file that includes the following: background-ima ...

Can you point me in the direction of the jQuery library link?

Can anyone assist me in locating the direct link to the jquery library for inclusion on my website? I have tried searching on the official website, but it doesn't seem to have the information I need or it's not clear enough. I only need the link ...

Attempting to establish a discussion board using MVC 5 on the ASP.NET platform

I'm currently facing a challenge while attempting to build a simple forum using ASP.NET MVC 5. Specifically, I am encountering an error message stating "The INSERT statement conflicted with the FOREIGN KEY constraint." Below, you can find the code sni ...

Obtain the URL of the chosen file from the input file in an HTML/AngularJS framework

Currently, I am developing a web app in MVC-5 using AngularJS. Below is the structure of the div that I am working on: <div class="row form-clearify" style="margin-top:3px;"> <div class="col-md-6 col-sm-6 col-xs-12" style="background-color:w ...

The collapsible menu located beneath my navigation bar is unable to reach the correct position on the right side

I'm attempting to create a collapsible navigation bar with its contents shifting to the right side when resized to medium size, but I'm having trouble. Can someone please assist me with this? I have also included the code below. <nav class=&qu ...

Adding a hyperlink to each table cell (td) in HTML and CSS that is visible outside of the table

In my table, there is a link on every td. I want these links to appear outside the table. Although I have achieved this, the first cell that was created needs to be hidden. When I try to hide the td using CSS, the link also disappears. Here is the HTML: ...

Tips for removing a previous file from an 'input type' in HTML5 FileReader

Here is a file input with an associated function: <img id="uploadPreview"> <div id="changeImage">Change</div> <div id="customImage"> <input type="file" id="myfile" multiple style="display:none" onchange="PreviewImage();" / ...