Tips for aligning tooltip bullets with label fields in a cohesive manner

I am trying to align the button next to the label and have the input field take up the full width below them. Here is what I have attempted:

<div class="container">
   <label>Tralala</label>
   <input type="text" placeholder="Tralalala">
   <button type="tooltip" data="This is tralalala">This is tralalala</button>
</div>
<div class="container">
   <label>Tralala Tralalala Tralalala</label>
   <input type="text" placeholder="Tralala Tralalala Tralalala">
   <button type="tooltip" data="This is Tralala Tralalala Tralalala">This is Tralala Tralalala Tralalala</button>
</div>

Unfortunately, I was unable to nest the button inside the label so I had to resort to using CSS to achieve the desired layout. Here is my CSS code:

.container {
    display: flex;
    flex-direction: column;
}
.container label { order: 0 }
.container input { order: 2 }
.container button {oder: 1 }

However, I am stuck on how to align the label and button inline with each other.

Answer №1

To achieve the desired layout, follow these steps:

1. Set the flex-direction to row and enable wrapping.

2. Adjust the order property so that the input element appears after the other elements and make it 100% wide.

.container {
  display: flex;
  flex-wrap: wrap;
  margin: 1em;
  border: 1px solid green;
  padding: 1em;
}

button {
  margin-left: 1em;
}

input {
  order: 2;
  flex: 0 0 100%;
  margin-top: 1em;
}
<div class="container">
  <label>Tralala</label>
  <input type="text" placeholder="Tralalala">
  <button type="tooltip" data="This is tralalala">This is tralalala</button>
</div>
<div class="container">
  <label>Tralala Tralalala Tralalala</label>
  <input type="text" placeholder="Tralala Tralalala Tralalala">
  <button type="tooltip" data="This is Tralala Tralalala Tralalala">This is Tralala Tralalala Tralalala</button>
</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 is the best way to incorporate regular, light, and bold fonts into your project using links from Google Fonts

I am looking for three specific styles of Ubuntu font without having to download them. To access these fonts, I inserted this link in the <link href="https://fonts.googleapis.com/css?family=Ubuntu:300,400,700" rel="stylesheet"> According to Google& ...

Incorporating an OpenID chooser in a webpage built with ASP.NET

Looking to integrate the OpenID selector from this link into a content page that is a child of a master page. What changes do I need to make? The issue is that my master page already has a form: <form id="form1" runat="server"> ... </form> ...

Tips for utilizing the onload attribute alongside the ng-controller directive to run a function that has been established within the controller

When trying to call the submit() function as soon as the page loads, I keep encountering a submit() method not found error. The positioning of ng-controller and onload is confusing to me. If there is an alternate method in Angular to achieve this, please ...

Switching between states using JavaScript

Here is a code snippet I'm working with: <!DOCTYPE html> <html lang="en" xmlns="http://www.w3.org/1999/xhtml"> <head> <title></title> <script src="C:\Users\rapandey\Documen ...

Creating dynamic form groups that allow for the addition and removal of forms while assigning unique identifiers and names to each input field

I am currently immersed in the development of a sophisticated CMS system. My main objective is to dynamically add and remove form inputs using JavaScript upon clicking a button, with the ultimate goal of submitting the data into a database via PHP script. ...

Can a full Angular component be integrated within Sweet Alert 2?

I'm curious if there's a way to have an angular component display in a Sweet Alert box, for instance. Swal.fire( { HTML: '<app-exampleselector></app-exampleselector>', }) What I had in mind was utilizing the compo ...

What is the best way to use jQuery to adjust the size of a slider image based on a percentage of the browser window

I've been searching all over for a solution to this issue, but so far I haven't had any luck. Basically, I have an image that is 1800 pixels wide by 500 pixels high. I need this image to adapt to all screen resolutions. Instead of having a fixed ...

The width of the Div element cannot be consistently preserved in Safari when viewing on an iPad

I'm facing a peculiar issue that seems simple at first glance, but has me stumped. On a webpage using Bootstrap, there's a div with the following code: .appSection{ background-color: #000000; padding:20px; border:1px solid #67c1d ...

Scrollable divs in a Bootstrap layout

If you take a look at this fiddle I created, you can see what I've attempted. My goal is to have a webpage without scroll bars but with the col-left and col-right divs getting a scrollbar when they overflow. Could someone provide some insight on what ...

What is the best way to place two stacked buttons side by side in an inline format?

I am trying to rearrange the layout of a bootstrap modal that includes two multiple select elements and two buttons. My goal is to have all controls inline, with the buttons stacked on top of each other. Here's an example of what I'm aiming for: ...

Illuminate the expanded dropdown menu in a Bootstrap 5 navbar

Bootstrap 5 navbar allows for the creation of dropdown menus. Is there a way to highlight the current menu item when a dropdown is opened, similar to how it's done in Windows desktop applications? This feature is not provided by Bootstrap 5: https:/ ...

Can one customize the background color of a segment in a radar chart using Chart.js?

Could I customize the color of the sectors in my radar chart to resemble this specific image? https://i.stack.imgur.com/U8RAb.png Is it feasible to achieve this using Chart.js? Alternatively, are there other chart libraries that have this capability? It ...

An illustration of HTML frames

Is this method effective? <html> <body> <center> <frameset rows="50%,50%"> <frame src="images.html"> <frameset> <form action="abc.html"> <input type="submit" name="abc page" value="abc page"> </form> & ...

Utilizing Vue 3 slot styles in a child component

Issue with Scoped Styling and Child Component: I am facing a problem while trying to style the contents of a <slot> within a child component using scoped css. Despite applying styles, they do not reflect as expected. The scenario involves two compon ...

Creating a scrollable container using CSS

I am currently working on a React project and encountered an issue with the CSS styling. I am looking for a solution that allows me to keep the parent and child components the same while enabling a scroll effect on the left side of the div containing shopp ...

Overlapping dynamic content causing CSS nested scrollbars to clash at full width of 100%

Displayed below is a layout with two nested divs, both featuring automatic vertical scrolling. Is there a CSS technique available to show the inner scrollbar while maintaining the inner div at 100% width? https://i.stack.imgur.com/HSKHH.png div { ba ...

placing a dropdown menu below the search bar

Let's say I have a container with an input search field. My goal is to position a select dropdown right below the search input, ensuring that the dropdown has the same width as the search input (similar to autocomplete functionality). Here's what ...

Transition the background image color smoothly from left to right in a seamless and continuous movement

A switch button located in the top right corner can toggle between light and dark modes. The background features a zoomed-in image. Currently, the transition is as follows: From left to right when switched to dark mode From right to left when switched to ...

Learn the steps to include an HTML checkbox in an AJAX HTML editor

I need help with adding an HTML checkbox to an Ajax HTML editor in ASP.NET. I have attempted to do this but am having trouble checking and unchecking it. Below is the code snippet that I have tried. Any suggestions would be greatly appreciated. webform.as ...

Unable to choose the div element with id ":1"

Just starting out with web development, and I have a div element with the following attributes: <div class="" id=":1" role="treeitem" aria-selected="false" aria-expanded="false" aria-level="1" aria-labelledby=":1.label" aria-setsize="10" aria-posinset= ...