Utilize Flexbox to create ample space on the right side

Hi there, I've noticed that when I use display: flex, the right side of my row seems to have a slight gap. How can I go about fixing this issue? It's not very obvious in jsfiddle, but you can spot it using Firebug or a similar tool.

Check out the jsfiddle here

I understand that the margin is causing this problem, but I still require the margin...


    <div class="input-group" style="display: flex; justify-content: space-between; align-items: center;">
        <input type="text" class="tile-txt" placeholder="Box 1">
        <input type="text" class="tile-txt" placeholder="Box 2">
    </div>

Answer №1

The reason this is happening is because the second (last) input element has a margin-right of 5px. To fix this issue, simply remove it and the layout will look as desired: Check out the DEMO here

.tile-txt:last-child{
    margin: 0 0 5px 0;
}

UPDATE:

If you have multiple rows, you should remove the margin from elements with an even index. Here's a link to the updated DEMO for reference: Updated DEMO

.tile-txt:nth-child(even){
    margin: 0 0 5px 0;
}

Answer №2

An alternative way to approach this would be by employing the use of an auto left margin, as flex items handle auto margins in a unique manner compared to block formatting contexts.

.right-side {
    margin-left: auto;
}

Check out the updated fiddle here

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

Exploring NodeJS Express Routing Across Various URIs/URLs

In my application, there is a public folder that contains HTML/CSS3/JS code. This folder has two main parts: one with the public facing index.html inside public/web and another with an admin view exclusively for admins. Below is the basic layout: public ...

What is the best way to design a group of radio buttons with corresponding labels at the top

I'm looking to create a structure like this in HTML: https://i.sstatic.net/wLcZs.png Does anyone know how I can achieve this layout so that the labels are aligned properly with the radio buttons? My main challenge is getting the horizontal labels ab ...

Create a layout using jquery-tokeninput

Currently, my project incorporates jQuery-tokenInput and everything is functioning properly. However, I now have the desire to customize the design of the results that are displayed. For example, I want to adjust the width or make any other design changes. ...

Issue with IE7 causing div elements to slide off the screen on specific WordPress pages

Encountering a strange IE7 bug on two pages of a WordPress site I'm currently developing. Some divs are shifting to odd positions, with one completely off the screen: and another here: Additionally, possibly related or not, the "created by" link in ...

What causes the lower gap to be smaller than expected when using "top: 50%; translateY(-50%);" on specific elements within the parent container?

My top-bar layout needs to have all elements vertically centered, but I'm experiencing issues with the top-bar_right-part not behaving as expected when using the core_vertical-align class. The left menu works fine, however. To illustrate the problem, ...

What is the best way to create a fade effect when toggling the class "hover"?

I've searched and searched online, but haven't found a solution. I want a specific section of my webpage to gradually appear when I hover over it. Below is the CSS code I'm using: .status .admin { display: none; } .status.hover .adm ...

Animate the sliding of divs using the JavaScript animation function

I've designed some boxes that function similar to notifications, but now I want to smoothly slide them in from the left instead of just fading in. I know that I need to use .animate rather than .fadeIn to achieve this effect. The code snippet I&apos ...

Smooth scrolling feature for Wordpress websites

I am currently in the process of converting an HTML5 template into a Wordpress theme. One specific feature I'd like to add is a custom scroll for Wordpress using the code: <script src="jquery.nicescroll.js"></script> DEPENDENCIES This cod ...

Interactive Navigation Bar in JavaScript

Is there a way to create a horizontal menu with an arrow that follows the mouse cursor? I saw this effect on a website (http://cartubank.ge) and I'm curious if anyone has the source code for it? Your help would be greatly appreciated. ...

Changing the type of value in a React select onChange

<Select options={options} value={selectedBusinessList} isMulti placeholder="Select Business" onChange={(value: any) => setSelectedBusinessList(value)} onInputChange={query => { if ...

Utilizing JSON data to generate an HTML webpage showcasing a collection of community districts through the power of JavaScript

As a beginner in javascript, I am working with a JSON file that contains an array of objects. Each object includes two properties: a borough and mappings. Mappings have two sub-properties called macro and neighborhoods. The macro represents a larger neighb ...

Disable automatic playback of HTML video

There is an HTML video with an image that loads initially and then disappears to play the video. I would like the image to always be visible until I click on it. Once clicked, the video should start playing. You can view the code on JSFiddle: http://jsf ...

Tips for creating a vertical scrollbar within a row component

Is there a way to create a scrollable parent v-row with a child v-row overflowing with content so that I can nest another v-row inside the v-col and ensure it remains within the scroll element? <v-row> <v-col> <v-row> <p ...

Use the 'url' parameter to pass into the ajax function when using jQuery for online requests

I am working with an ajax code that retrieves data from an XML file locally. <script> function myFunction() { $("#dvContent").append("<ul></ul>"); $.ajax({ type: "GET", url: "test.xml", ...

Is there a way to continuously click on a button 99 times or until the code finishes running?

Need Assistance, Please Assist. I am encountering an issue where I have the same type of skip button with identical name and id properties for all products, but only the xpath changes. Can you provide guidance on how to efficiently click on 99 similar ski ...

When placed within a <li> element, the <a> tag will not create a hyperlink to a page, but it will

I have encountered an issue with my anchor links. All of them are working properly except for the one in the second ul with an href="page1". Interestingly, the link shows the correct destination at the bottom left of my screen and works when I right-click ...

What is the best approach for adding a mark within a circle using React or vanilla JavaScript?

Has anyone come across an npm package that allows for marking a dot in a circle? I am looking to click on the mark and output the JSON object. https://i.sstatic.net/u8FTY.png Additionally, is there any option to achieve this with a simple onClick event? ...

Intercepting 401 with Angular 5 HTTP Interceptor recognizes it as status code 0

One issue I am currently facing is the inability to intercept a 401 status and redirect to the login page, which is a common practice in most applications. My interceptor code seems pretty standard: intercept(request: HttpRequest<any&g ...

Ways to implement CSS styling for a particular HTML element

HTML: <div class="tagline">Web Portal Name</div><br /> <div id="logged_in_user_dtls" style="color:#FFF; margin-top:15px; font:bold; width:100%; position:relative; margin-left:800px;float:left;"&g ...

Preventing text and images from distorting when zooming on a website

Currently, the HTML page I'm working on has some issues when zoomed in. The paragraphs seem to break out of their designated area and display as vertical lines of text instead of staying horizontal. Additionally, the pictures on the site become overly ...