Is there a way for the span element to disregard columns?

I am currently developing a web application where users can drag boxes containing words/phrases into a designated area. These boxes have tooltips that display the definition of the word when hovered over. I want the dragged boxes to fall into two columns within the area, but I'm encountering issues with tooltips breaking when they go beyond the edge of the column. Is there a solution to this problem?

Current Tooltip Display

Desired Tooltip Display

#div1 {
        float: left;
        width: 328px;
        height: 400px;
        margin-left: 4px;
        padding: 10px;
        border: 1px solid black;
        border-radius: 6px;
        background-color: white;
        -webkit-columns: 2;
        -moz-columns: 2;
        columns: 2;
        -moz-column-fill: auto;
        column-fill: auto;
      }

      .box {
        height: 54px;
        width: 160px;
        text-align: center;
        background-color: white;
        color: purple;
        border: 1px solid black;
        border-radius: 4px;
        margin-bottom: 2px;
        position: relative;
        text-align: center;
      }

      .tooltiptext {
        visibility: hidden;
        width: 160px;
        background-color: purple;
        color: #fff;
        text-align: center;
        border-radius: 6px;
        padding: 5px 0;
        position: absolute;
        z-index: 1;
        top: 100%;
        left: 50%;
        margin-left: -80px;
      }

      .box:hover .tooltiptext {
        visibility: visible;
      }
<div id="div1" ondrop="drop(event)" ondragover="allowDrop(event)">
        {% for c in cards1 %}
        <div id="drag{{c.id}}-{{c.carddata.position}}" class="box" draggable="true" ondragstart="drag(event)">
          <span class="tooltiptext">{{c.carddata.description}}</span>
          <div id="text{{c.id}}-{{c.carddata.position}}" class="text"><br>{{c.carddata.name}}</div>
        </div>
        {% endfor %}
      </div>

Answer №1

If you change the display property of .box to inline-block, it will prevent it from spanning to the next column :

#div1 {
  float: left;
  width: 328px;
  height: 250px;
  margin-left: 4px;
  padding: 10px;
  border: 1px solid black;
  border-radius: 6px;
  background-color: white;
  -webkit-columns: 2;
  -moz-columns: 2;
  columns: 2;
  -moz-column-fill: auto;
  column-fill: auto;
}

.box {
display:inline-block;/* to keep in a single column */
  height: 54px;
  width: 160px;
  text-align: center;
  background-color: white;
  color: purple;
  border: 1px solid black;
  border-radius: 4px;
  margin-bottom: 2px;
  position: relative;
  text-align: center;
}

.tooltiptext {
  visibility: hidden;
  width: 160px;
  background-color: purple;
  color: #fff;
  text-align: center;
  border-radius: 6px;
  padding: 5px 0;
  position: absolute;
  z-index: 1;
  top: 100%;
  left: 50%;
  margin-left: -80px;
}

.box:hover .tooltiptext {
  visibility: visible;
}
<div id="div1">
  <div  class="box">
    <span class="tooltiptext">c.carddata.description c.carddata...description c.carddata.name<br/>c.carddata.name</div>
  </div>
  <div  class="box">
    <span class="tooltiptext"> c.carddata.description c.carddata.description c.carddata...ame<br/>c.carddata.name</div>
  </div>
  <div  class="box">
    <span class="tooltiptext">c.carddata.description c.cardd...c.carddata.name<br/>c.carddata.name</div>
  </div>
  <div  class="box">
    <span class="tooltiptext">c.carddata.description c.car...me<br/>c.carddata.name</div>
  </div>
  <div  class="box">
    <span class="tooltiptext">c.carddata.descripti...name<br/>c.carddata.name</div>
  </div>
  <div  class="box">
    <span class="tooltiptext">c.carddata.de...e<br/>c.carddata.name</div>
  </div>
  <div  class="box">
    <span class="tooltiptext">c.card...ame<br/>c.carddata.name</div>
  </div>
</div>


Considering the fixed height, an alternative approach is using flex properties on the parent container:

  display:flex;
  flex-flow:column wrap;

(Column CSS is still experimental and may not receive further updates)

#div1 {
  float: left;
  width: 328px;
  height: 250px;
  margin-left: 4px;
  padding: 10px;
  border: 1px solid black;
  border-radius: 6px;
  background-color: white;
   display:flex;
  flex-flow:column wrap; 
}

.box {
  height: 54px;
  width: 160px;
  margin:0 5px 0 0;
  text-align: center;
  background-color: white;
  color: purple;
  border: 1px solid black;
  border-radius: 4px;
  margin-bottom: 2px;
  position: relative;
  text-align: center;
}

.tooltiptext {
  visibility: hidden;
  width: 160px;
  background-color: purple;
  color: #fff;
  text-align: center;
  border-radius: 6px;
  padding: 5px 0;
  position: absolute;
  z-index: 1;
  top: 100%;
  left: 50%;
  margin-left: -80px;
}

.box:hover .tooltiptext {
  visibility: visible;
}
<div id="div1">
 
  ...
  
</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

What could be causing the DIV elements to not align side by side?

<div id="dvFirst" class="mainSecond" style="background: #6FA5FD;"> <div id="leftdiv3" class="leftdiv">Client: </div> <div id="rightdiv3" class="rightdiv"><asp:DropDownList ID="ddlCliNewMsg" AutoPostBack="t ...

How to position an empty Div next to images

I am currently working on a project to familiarize myself with Japanese Hiagana. I plan to incorporate more images and eventually sound into the post. To reduce the number of images used, I attempted to replace empty .pngs with a div element. However, I am ...

How to modify duplicated elements in JavaScript?

Imagine having text input A. Developing a new form element, F, using javascript without connecting it to the DOM is the next step. Subsequently, an input B (a copy of input A) is attached to F. Input B aims to replicate input A, therefore an event listener ...

What is the best way to design a page with a fixed dimension element and a flexible liquid element?

Is there a way to achieve the layout described below without relying on tables? Left element (100px) | Right element (occupies remaining space, even with no content) Thank you! Edit: Here's the link to the code: http://pastebin.com/vU33jNxD ...

The alignment of my divs is completely off

While working on my website, I've encountered a bit of a snag. I'm having trouble getting my divs to line up correctly for events, news, and three middle descriptions. Here's the code (please excuse any messiness...I'm in the process o ...

Solution for dropdown boxes malfunctioning with required fields

Using Bootstrap 3 for field validation on forms has been effective, but there seems to be an issue with certain browsers such as ios safari not validating [required] form items. To address this, I created a script that checks if an element is marked as req ...

Is the in-app browser of WeChat able to support self-signed HTTPS URLs?

My local WAMP server hosts a web application with self-signed SSL enabled, resulting in the following app URL: https://myipaddress:port/demoapp/index.html However, when I send this URL via WeChat chat and click on it, only a blank page is displayed. Stra ...

Troubleshooting CSS Problems: Issues with background repeating and footer placement

I am currently in the process of transitioning my website to a CSS layout, and so far it's looking good. However, I am facing two specific issues with the page layout that I need help with: 1) The background image of the left-most column is not repea ...

Disable the border and background colors in CloudFlare Turnstile

I have implemented the CloudFlare reCaptcha Turnstile and I am looking to modify the widget by removing the border and background color. I believe this customization can be achieved using CSS or Javascript. Thank you for any assistance! ...

Text hidden within the image, each line concealing a separate message

I am having an issue where my image is overlaying the text. I would like the text to wrap around the image and for any hidden text to appear on a different line. How can this be achieved? Here is the CSS code I am using: div.relative { position: relati ...

Exploring the functionality of Django's detail view with a set of primary keys

Within my program, the main page displays a table listing various products, with a checkbox next to each product and a dropdown menu for selecting price levels (e.g. Retail, Distributor). When a user chooses a price level and selects multiple products by c ...

I'm experiencing an issue where the Devtool appears empty when inspecting it, making it impossible to locate

I'm currently working on automating the process of entering data into web forms using Selenium VBA. The forms are located on our organization's SharePoint site, and I have already logged into the account. However, every time I reach the final ste ...

How can we determine if the user is on a small device and utilizing flexbox with col-sm?

Is there a method to detect when the user is on a small device? I'm looking to adjust my navigation menu based on the size of the device, similar to the col-sm functionality. ...

Animating object on display and returning it with keyframes

Given the code snippet below: <div class="leftBox"> <div class="mainNode" ></div> </div> <script type="text/javascript"> $('.mainNode').click(function() { var element = $('.mainNode'); if (!ele ...

Combining Django and gunicorn to share app-level variables among multiple workers

I am working on a toy django + gunicorn project and I have a large statistical model that I want to load into memory only once and then reuse it in the workers/threads. Where and how should I define an app level variable for this purpose? I have tried put ...

View content from an external file within an iframe

My goal is to showcase a text file within an iframe that updates automatically every second. To achieve this, I have created a simple function: function refresh() { $("#derek").attr('src', $("#derek").attr('src')); }; The automati ...

Vertical alignment of content over image is not in sync

I am attempting to center my div container .home-img-text vertically in the middle of its parent div .home-img. Despite trying various methods such as setting .home-img-text to position: absolute, relative, adding padding-top, and several others, I haven&a ...

The DRF UpdateAPI View response includes the message: "Could not be located."

Whenever I attempt to update my DRF endpoint using PUT or PATCH, I receive a 404 error with the message "Not found." I'm unsure of the source of the issue, whether it lies within my view or serializer. I've noticed that the documentation provide ...

Django - the art of transforming into Unicode

I am struggling with a Unicode issue once again and feeling completely lost, as usual. My Django template is throwing a TypeError: Exception Value: coercing to Unicode: need string or buffer, long found The problematic line consists of a string (wh ...

Having trouble with Python Selenium CSS Selector? If your element is not visible, it

My goal is to search for all hyperlinks on a webpage that contain an XML download link and download them in a continuous loop. When I click on these hyperlinks, a form pops up that needs to be completed before I can proceed with the download. However, I ...