Spacing between elements in a bootstrap container-row-column can be adjusted using whitespace

I find myself facing an unexpected challenge with whitespace appearing mysteriously within a list of dropdown items that I have created. Visually, it presents as follows:

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

The HTML code causing the issue (using bootstrap 4.3.1) is shown below:

 <div class="container">
    <div class="row">
        <div class="col">
            <center>Test Column</center>
            <div class="dropdown">
                <li><a href="#">Test text 1<span>&#10003;</span></a> </li><br>
                    <a href="#">
                        <div class="dropdown-content">
                            <p>Dropdown item 1</p>
                        </div>
                    </a>
            </div>
            <div class="dropdown">
                <li><a href="#">Test text 2<span>&#10003;</span></a> </li><br>
                    <a href="#">
                        <div class="dropdown-content">
                            <p>Dropdown item 2</p>
                        </div>
                    </a>
            </div>
        </div>
    </div>
</div>

The CSS relevant to this issue is outlined below:

/* Ensure each list item appears on a separate line */
ul {
display: inline;
}

/* Styling for visited links */
a span {
color: white;
}
a:hover {
text-decoration: none;
}

a:visited span {
color: green;
}

/* Dropdown Menu */
.dropdown {
position: relative;
display: block;
}

.dropdown-content {
display: none;
position: absolute;
overflow: hidden;
background-color: #f9f9f9;
box-shadow: 0px 8px 16px 0px rgba(0,0,0,0.2);
padding: 12px 16px;
z-index: 1;
left: 20%;
}

.text-window {
min-width: 320px;
min-height: 480px;
}

.dropdown:hover .dropdown-content {
display: inline-block;
}

The issue has also been replicated in this JSFiddle.

Answer №1

Instructions to eliminate the <br> tags from this specific line:

<li><a href="#">Test text 1<span>&#10003;</span></a> </li><br>

Answer №2

Make sure to eliminate the breakpoint
from your li HTML code.

Break tags create unnecessary space between elements, causing them to move to the next line.

<div class="container">
    <div class="row">
            <div class="col">
                <center>Test Column</center>
                <div class="dropdown">
                    <li><a href="#">Test text 1<span>&#10003;</span></a> </li>
                        <a href="#">
                            <div class="dropdown-content">
                                <p>Dropdown item 1</p>
                            </div>
                        </a>
                </div>
                <div class="dropdown">
                    <li><a href="#">Test text 2<span>&#10003;</span></a> </li>
                        <a href="#">
                            <div class="dropdown-content">
                                <p>Dropdown item 2</p>
                            </div>
                        </a>
                </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

I'm perplexed as to why my webpage displays differently across various browsers

Currently, I am utilizing the Yahoo CSS reset and all my CSS is based on pixel values rather than relative units like ems. Interestingly, there seems to be a discrepancy in the position of the bottom right corner of the form-containing div between Chrome a ...

Delivering Access data in HTML format via email

In my MS Access database, I have a report that combines client records from one table (including email addresses) with grouped records fetched from other tables using a Query. I want to send this report directly to each client via email, within the body o ...

Is it possible to personalize the Carousel-indicators feature within react-responsive-carousel?

I am currently utilizing the react-responsive-carousel library. I would like to modify the default indicators CSS, changing the dots shape to a line shape. Here is my code snippet: <CarouselWrapper sx={{ marginTop: "124px", maxHeight: & ...

Button in Angular gets stuck when a touchscreen is long pressed

In my Angular2 application, I am facing an issue with a button when running on a Windows 10 touchscreen PC in Chrome. Normally, the button works fine and executes the click function. However, if the button is held for 1-2 seconds, it gets stuck and fails t ...

How about, "Enhance your website navigation with a sleek anchor

After many attempts to implement smooth scrolling on my Bootstrap project, I have tried numerous Youtube tutorials and Google search results without any success. The latest attempt I made was following this Stack Overflow post Smooth scrolling when clickin ...

Avoid Scroll Below Stuck Navigation

I've been searching for a solution to my issue for some time now, and while I've come across many articles discussing similar problems, none of them seem to address my specific problem. In my React app, I have a mobile version where users can ta ...

Resize the shape of an image's polygon

Is there a way to independently scale a specific polygon of an image on hover? For example, I have a world map and I would like to enlarge a country when hovering over it, then return it to its original size when no longer hovering. I am familiar with us ...

The horizontal scroll feature is dysfunctional when attempting to allocate cell space based on a percentage

I want to display two sections of text that take up the full width of the screen and resize automatically when the screen size changes. Currently, I am using percentage widths to achieve this. However, when the text inside a section exceeds the available ...

An unusual html element

During a recent exploration of a website's code using the inspect tool, I stumbled upon a tag that was completely unfamiliar to me. <gblockquote></gblockquote> I've come across a blockquote before, but never a gblockquote. Interest ...

Video not visible in program (CSS, EXPRESS)

I am struggling to add a video to my page. The default method of creating a path for it isn't working for me. I believe I need to place the path somewhere else, but I'm not sure where. I have attempted to include the video in the same folder as ...

Utilizing HTML5 for page-relative translation

Is there a way to apply a translate to an element so it moves to a specific point on the page instead of relative to its starting position? For instance, in the code snippet below, the "card" elements will move 50, 100 relative to their initial position. ...

Is a Selenium loop a viable option?

</head> <body> <table cellpadding="1" cellspacing="1" border="1"> <thead> <tr><td rowspan="1" colspan="3">test</td></tr> </thead><tbody> <tr> <td>click& ...

"Exploring the relationship between UIWebView and CSS's fixed positioning

My UIWebView is set up with a fixed position header. Everything works seamlessly when the initial view of the ViewController containing the UIWebView is displayed. However, if I present that same ViewController using a Modal segue, an issue arises. When ...

Increase the size of the card-footer on the final Bootstrap 4 card to completely fill the space

I have been experimenting with different flex combinations to try and stretch the final card-footer to occupy the leftover space if there are no buttons present, but haven't had much success. <link href="https://stackpath.bootstrapcdn.com/boot ...

Modifying Stroke color in HTML5 Canvas

I am attempting to create a unique visual effect by drawing a circle resembling a clock using canvas 2d context. The idea is to initially draw the circle in black starting at point p1, and then when I complete a full circle tour it should erase as the colo ...

Is it possible to invoke a mixin using a variable name?

I currently have around 50 mixins in my codebase, each generating specific elements. However, I am interested in creating a single mixin that can call any of them based on their name, rather than using a long if statement chain. Is there a method to invoke ...

What is the best way to set a newly selected HTML option as the first choice?

I'm facing a simple problem in JavaScript that I can't seem to crack. Admittedly, I am new to working with JavaScript. My issue lies with sorting a dropdown list in alphabetical order while also keeping the selected value at the top. Whenever a ...

Error Message: Only integers can be used as string indices - Issue encountered while rendering bundle in Vue.js and Django

Utilizing webpack loader to inject my Vue app into Django. Below is the code snippet: Settings: WEBPACK_LOADER = { 'DEFAULT':{ 'BUNDLE_DIR_NAME':'/', 'STATS_FILE':os.path.join(BASE_DIR,'aptim-frontend/ ...

A Guide to Retrieving the First Child Element's Text with Jquery and a Class Selector

I want to extract the text from the first child small element inside a dynamically generated div. The structure looks like this: <div class="NDateCount" style="display:inline-block"> <!--Issue to solve--> <small ...

Positioning html images to overlap each other without losing the ability to click

Currently, I am facing a challenge with positioning two images over each other. The back image should be at the bottom, while the center image needs to be on top of it. Additionally, there is a requirement for placing a random link (in this case google.com ...