Create Stylish Popups and Spacious Containers with CSS

A unique pure css popup was crafted by merging and . Hovering over "John Smith" triggers the appearance of the popup. The code for this can be seen at http://codepen.io/kikibres/pen/MwEgQX.

However, there are some challenges being faced. The aim is to keep everything aligned to the right side of the page while remaining within the designated container. Attempts were made by removing the

"overflow: hidden; height: auto;"
from .quotename. However, upon removal, the popup extends beyond its boundaries. Reinserting the code keeps the elements contained but causes issues with the functionality of the popup. How can this be addressed?

HTML

<div class="testimonials">
        <div class="container">
            <div class="quotename">
                <a href="#" class="tooltip">
                <span><h3>Mini profile</h3>Lorem ipsum dolor sit amet, consect etur adipiscing elit.</span>
                <h2>John Smith</h2></a>
            </div>
        </div>
    </div>

CSS

.testimonials { background-color: #e7d6e9; padding: 30px 0;}
.container { width: 90%; margin-left: auto; margin-right: auto; background-color: #e9e9e9;}
.quotename {  margin: 20px 0; position: relative; /*overflow: hidden; height: auto;*/}
a.tooltip {outline:none;}
a.tooltip h2 { text-decoration: none; border-bottom: 2px solid #00acb6; font-family: 'Montserrat', sans-serif; font-weight: 700; font-size: 20px; color: #00acb6; float: right; width: auto; margin: 0;}
a.tooltip strong {line-height:30px;}
a.tooltip:hover {text-decoration:none;} 
a.tooltip span {
    display:none; 
    padding:14px 20px;
    margin-top:-120px; 
    margin-right: -8px;
    width:150px; 
    line-height:16px;
    background: #e9e9e9;
    height: 70px;
    position: relative;
    float: right;
}
a.tooltip span h3 { margin:0;}
a.tooltip span:after, a.tooltip span:before {
    top: 100%;
    left: 75%;
    border: 3px solid transparent;
    content: " ";
    height: 0;
    width: 0;
    position: absolute;
    pointer-events: none;
}
a.tooltip span:after {
    border-color: rgba(0, 172, 182, 0);
    border-top-color: #e9e9e9;
    border-width: 10px;
    margin-left: -10px;
}
a.tooltip span:before {
    border-color: rgba(0, 172, 182, 0);
    border-top-color: #00acb6;
    border-width: 14px;
    margin-left: -14px;
}
a.tooltip:hover span{
    display:inline; position:relative; color:#111;
    border: 3px solid #00acb6; background: #e9e9e9; border-radius: 6px;}
a.tooltip span
{
    border-radius: 6px;
    border: 3px solid #00acb6;
}

The current code allows the popup to function but results in overflowing elements. A modified version of the code that maintains proper boundaries can be found at http://codepen.io/kikibres/pen/BNwaGq. It is imperative that no Javascript is utilized for this solution.

Further investigation revealed that the floats in a.tooltip span and a.tooltip h2 could impact the layout, potentially causing elements to overflow their containers. Additionally, it was observed that eliminating the float:right property from a.tooltip h2 rectified most issues except for the full-width bottom border which may require alternative solutions. Reference to addressing this issue can be accessed via Is it possible to extend a h2 box in CSS depending on the text within it?. The updated code can also be viewed at http://codepen.io/kikibres/pen/RPLwmy

Answer №1

Eliminate the margin-top attribute from the specified class a.tooltip span{}. Check out the demonstration.

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

How to efficiently insert multiple values into a MySQL database by utilizing a single HTML option

I'm currently facing an issue with a section of my form. I can't seem to figure out what's causing the problem, so I've decided to reach out here for some guidance. The code I've written aims to determine both the gender and sexua ...

Restrict the number of rows in a CSS grid

Hello there, I am in the process of creating an image gallery using CSS grid. Specifically, my goal is to initially show just one row of images and then allow users to click a "Show more" button to reveal additional images. You can see my progress here: ...

GWT integration for TinyMCE

I've been attempting to incorporate TinyMCE with GWT's RichTextBox, but so far I haven't had any luck. The issue seems to be that GWT turns the Rich text area into a #document, rather than a standard textarea in HTML. Does anyone know how to ...

The Twitter quote button refuses to function properly if there happens to be a pesky semicolon present in the quote

I have been working on setting up a Twitter share quote button, and have successfully done so with my other quotes. However, I am facing an issue with a quote that includes a semicolon. <a href="http://twitter.com/home/?status=Don\'t talk a ...

Change the z-index of divs when clicked

When a button is clicked, I want to iterate through a group of absolutely positioned children divs with varying z-indexes. The goal is for the z-index of the currently visible div to decrease on each click, creating a looping effect where only one div is v ...

Every fourth list item, beginning with a designated number

I'm attempting to add a border to specific list items in my HTML. I want the border to start from the 9th child and then continue every 4th child after that. For clarification, I'd like the 9th, 13th, 17th, 21st, 25th... list items to have white ...

Pause the counter based on the data attribute containing multiple values

I have a collection of div elements, each with a unique data-attribute value. My goal is to display these values in the divs using JavaScript by incrementing a counter. const numbers = document.querySelectorAll(".number"); console.log(numbers); let c ...

The Window.print() function may experience compatibility issues across different browsers

When attempting to utilize the Window.print() function, I encountered an issue where it works perfectly in Google Chrome but not in Mozilla Firefox. Attached are screenshots displaying the problem at hand. What could be causing this discrepancy? Furthermor ...

What are some ways to ensure keyboard accessibility for a CSS drop-down menu?

I have come across some solutions, but I am struggling to incorporate them into my code as some require elements that are not compatible with my project. Let's get to the question: I need help making an existing CSS drop-down menu accessible for key ...

What causes <input> elements to vertically center when using the same technique for centering <span> elements? (The line-height of <input> does not match its parent's height)

Important: The height of <div> is set to 50px, and the line-height of <span> is also 50px When 'line-height' is not applied to the <span>, all elements align at the top of the parent. However, when 'line-height: 50px&apo ...

styling the search input element in webkit with right-to-left text direction

I have included a search input in my code like this: <input type="search" placeholder="search" /> Webkit has different styles for an input field with the type 'search'. One of these styles is displaying a cancel ('x') button on ...

Develop a custom dropdown menu using JavaScript

I've been working on creating a dropdown menu that appears after selecting an option from another dropdown menu. Here's the HTML code I'm using: <br> <select id ="select-container" onchange="addSelect('select-container') ...

Retrieving text from a draggable div using jQuery

I have a draggable div that I can move over another element with the class .outerDiv which contains text content. Is there a way for me to retrieve the text from .outerDiv that overlaps with the draggable div? $(".outerDiv .isStore").draggable({ contain ...

retrieve the month and year data from the input date

I encountered a situation where I'm working with the following unique HTML code: <input type="date" id="myDate"/> <button type="button" class="btn btn-secondary" id="clickMe">MyButton</ ...

The curly braces in AngularJS are failing to display the values on the HTML page

After trying various articles and solutions to different questions, I am still unable to resolve my issue. I am working on a blank ionic project and it is running smoothly in my browser using ionic serve without any errors. However, instead of displaying ...

Utilizing HTML in Grails messages.properties for email delivery: A beginner's guide

When working with Grails, I have implemented a GSP template to generate an HTML email using the mail plug-in. Everything functions properly, except for one issue - the GSP template utilizes a parameter that is retrieved from my messages.properties file. I ...

The order of event handlers in jQuery

I am currently setting up event binding for a text element dynamically. Take a look at the following code snippet: <input type="text" id="myTxt" /> <script type="text/javascript"> function attachEvent1(element){ element.keyup(func ...

Sending Django Variable With Javascript

As a newcomer to Javascript, I am grappling with retrieving the value of a variable from my HTML form. My current code seems to be somewhat functional - I added an alert to test the logic and found that the else statement is working fine. However, I'm ...

Modify the hover color of heading 1 only for hyperlink texts

I am attempting to adjust the hover color specifically for text that contains a link. Below is the CSS code I have tried, but it changes the color regardless of whether there are links present or not. h1, h2, h3, h4 { color:#3F3F3F; } h1:hover, h2:hove ...

What steps can I take to ensure my CSS component remains unaffected by the global CSS styles?

My navbar component is not displaying the styles correctly as intended. I have a Navbar.module.css file to style it, but after using next-auth for social login, only the buttons remain unstyled while everything else gets styled. The code snippet for impor ...