CSS display property can be used for efficient line filtering

I used a timeline layout example in the JSFiddle where I added filter buttons. However, when I click on the TEST or GROEP button, the middle line gets cut off. Can anyone assist with this issue?

Refer to:

https://jsfiddle.net/tc2axpkf/11/ Click on the TEST or GROEP button and observe the truncation of the middle line.

.timeline:before {
top: 0;
bottom: 0;
position: absolute;
content:" ";
width: 2px;
background: #ffffff;
left: 50%;
margin-left: -1.5px;
}

Answer №1

You have encountered floating elements that need to be cleared.

.timeline {
    list-style: none;
    padding: 10px 0;
    position: relative;
    font-weight: 300;
    overflow:hidden; /* should suffice */
}

Refer here for more information: https://css-tricks.com/all-about-floats/#article-header-id-4

If you know the succeeding element in your situation, you can apply clear: both; to that element without any complex hacks or extra elements, keeping it semantic. However, things usually aren't that simple and we may need other methods for clearing floats.

In your scenario, consider using:

The Overflow Method

The Overflow Method involves setting the overflow CSS property on a parent element. When set to auto or hidden, the parent will expand to contain the floats and clear them for subsequent elements. This method is quite semantic as it often doesn't require additional elements. But adding a new div solely for this purpose may not be as semantic and adaptable. Also, remember that the overflow property isn't exclusively for clearing floats, so take care not to hide content or create unwanted scrollbars.

Answer №2

Upon inspection, it appears that the .timeline-inverted portion has been eliminated from the document object model. Subsequently, your .timeline structure collapses due to floated elements.

To resolve this issue, consider implementing a clearfix:

.timeline:after {
  content: "";
  display: block;
  clear: both;
  height: 0;
}

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

JavaScript tag filtering system: Display only the div elements that contain all the specified classes in an array; otherwise, hide them

Can you provide some guidance on accomplishing this task? I am looking to toggle the visibility of a div based on its classes and an array. If the array contains the term something, then only divs with the class something will be displayed. If the array ...

What is the best way to present a specific row layout using HTML and CSS?

Can someone assist me in creating rows of links in html+css with a specific layout? The desired format should follow this structure: (Psuedocode) <body class="class_with_minmaxwidth_set_in_css"> <div class="container"> <div class ...

css adaptive, dimension control, and alignment

I am currently working on developing a responsive website. The layout includes a picture on the left side, main content in a div on the right side, and additional content below the picture (view screenshot here). I want the main content to be the same heig ...

Conceal the object, while revealing a void in its place

Is there a way to hide an image but keep the containing div blank with the same dimensions? I want it to appear as if no content was there, maintaining the original width and height. For example: http://jsfiddle.net/rJuWL/1/ After hiding, "Second!" appea ...

Enhancing the aesthetic appeal of a form

I have created a form in HTML that utilizes JavaScript to pull data from a database. I am looking to style the form, but I'm unsure of how to proceed. Below is the form along with some CSS code. How can I integrate the two together? <form id=" ...

I created some jQuery code that modifies a button when it is hovered over, however, I ended up writing the code individually for each button. What steps can I take to turn it

Is there a way to turn the code for each button on my website into a jQuery function that can be applied to any button? This is how the code currently appears: $(document).ready(function() { $("#linkXML").hover( function() { ...

How come only half of my website is inaccessible when utilizing a sticky navigation menu, and what can be done to remedy this issue?

I've successfully implemented a menu on my website that stays fixed at the top of the page while scrolling. However, there is an issue where I am unable to click on the top 50% of the screen, rendering the website unusable. You can view a test copy of ...

Text alignment from the lower edge

Imagine having a title inside an image, positioned near the bottom with a negative margin-top. The issue arises when the text orientation expands from top to bottom as more content is added. Is there a way to reverse this, so that the text div grows toward ...

What is the best way to create equal space between divs while also adjusting the left and right space based on the width of the

Is it possible to create equal space between div elements while also ensuring that the spacing adjusts based on the width of the browser? The goal is to center the divs and have consistent left and right margins that change depending on the browser width ...

Increase the border thickness on the top side of the div

To enhance the design of the .menu div, I decided to include an additional border at the top. Initially, I incorporated top and bottom borders using box-shadow, followed by traditional borders using border-bottom, border-left, and border-right properties. ...

Contact on the go with our handy mobile contact form

Having some difficulties with the contact form on my website. The link to the form is: here. I am currently working on making the form mobile-friendly (the rest of the site scales down using @mobile screen tags in the CSS). The form is stacked, so there ...

I'm not sure what's causing the issue with my image URL not functioning properly

Here is the path to the image I am trying to display: https://i.sstatic.net/Vn6SA.png This is the code snippet I have in my file: <div class="container-fluid"> <a class="navbar-brand" href="/"> <img src= ...

Leveraging SignalR in conjunction with jQuery to dynamically alter the CSS style of a span

Utilizing SignalR to dynamically update a span's color based on real-time data source. The connection is established successfully, but encountering difficulties with updating the css classes on the span. The issue arises when attempting to update mul ...

Protected Bootstrap Environment

Bootstrap is an amazing tool, but it tends to enforce too many opinions. The selectors used in its rules are quite broad, such as input or label. Is there a method to isolate Bootstrap's CSS so that it only impacts elements within a container with a ...

Text aligns with the curve, ViewBox trims the characters

I'm stuck with an issue regarding a rotating text on a circle. The problem is that the copy gets cropped by the viewbox. I've tried adjusting the viewbox parameters to "zoom out", but whenever I change the current value of 141, instead of zooming ...

Mastering card sliding and spacing in React NativeLearn how to effortlessly slide cards horizontally in your React

My aim with the following code snippet is to achieve two objectives: Apply a margin of 20 units to each card Display all four cards in a single row, allowing users to swipe horizontally Unfortunately, I have not been successful in achieving either of th ...

Tips on playing HTML video only when it is in the user's view

Currently, I am working on a TikTok-inspired UI project. However, I am facing an issue where videos do not autoplay when they come into view after scrolling, similar to how it works on TikTok. Here is a demo for reference. Below is a snippet of my code: ...

Tips for designing posts within a Bootstrap card column

I have a code snippet for displaying posts in a bootstrap card column layout. %h4{:align => "center"} All Posts %hr.my-3 - @posts.each do |post| %h4= link_to post.title, post %p= post.description %p= post.company I am looking to display the firs ...

What is the best way to make sure that the parent div of an svg shows its shadow on top of the svg itself?

I am in the process of creating an interactive world map using an SVG map. The SVG format is necessary because I have implemented functionality to zoom in and move the map around. However, a challenge has arisen: the SVG element is obstructing the shadow o ...

Unveiling the secrets to isolating elements from a list based on distinct characteristics

Currently, I am attempting to scrape job skills from the Wuzzuf website using the following code snippet: result = requests.get("https://wuzzuf.net/search/jobs/?q=data+analysis&a=navbl") src = result.content soup = BeautifulSoup(src, "lx ...