Utilize flex to arrange the elements in a li layout

Can someone help me figure out why the code below is not working as expected?

I need the content of the 2nd option ("Log when error occurs and limit ...") to be enclosed in a yellow background.

.flex{
  display: flex;
  display: -webkit-flex;
  display: -moz-flex;
  display: -ms-flexbox;
  display: -ms-flex;
  position: relative;
  min-height: 0;
  min-width: 0;
}

.flex--1{
  flex: 1 1 auto;
}

.flex--0{
  webkit-flex-grow: 0;
  -webkit-flex-shrink: 0;
  -moz-flex: 0;
  flex: 0 0 auto;
}

input[type=radio].radio-button + label.radio-label {
    padding-left: 20px;
    height: 16px;
    display: inline-block;
    line-height: 16px;
    background-repeat: no-repeat;
    background-position: 0 0;
    font-size: 14px;
    vertical-align: middle;
    cursor: pointer;
    color: #666666;
}

li {
  list-style-type: none;
  display: list-item;
}
<ul class="form__group">
    <li>Send messages</li>
    <li>
        <input type="radio" name="log-options" class="radio-button" id="log-options-always" value="0">
        <label for="log-options-always" class="radio-label ng-binding">always</label>
    </li>
    <li class="flex" style="background-color: yellow;">
        <div class="flex--1">
            <input type="radio" name="log-options" id="log-options-when-error" class="radio-button" value="1">
            <label for="log-options-when-error" class="radio-label">Log when error occurs and limit log cache to...</label>
        </div>
        <div class="flex--0 width--lg disabled" ng-class="{disabled: data.Log.AutoLog !== '1'}">
            <input type="text">
            <span>KB</span>
        </div>
    </li>
</ul>

Check out the JSFiddle link too.

Answer №1

To ensure the element grows with its content, you should add a min-height property like so:

input[type=radio].radio-button + label.radio-label {
    padding-left: 20px;
    min-height: 16px;

A quick tip here:

It's best to use either an external CSS file (recommended) or inline styles, but not both together.

For instance, instead of:

<li class="flex" style="background-color: yellow;">

You can opt for this:

HTML

<li class="flex yellowBg">

CSS

.yellowBg {
    background-color: yellow;
}

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

The Tinymce filemanager is completely unresponsive and the language settings are failing to load

Encountering an issue with tinymce's filemanager functionality. Attempted to establish a connection but ran into some trouble. When selecting text and trying to create a link, upon clicking the "chain" icon and then the "browse" button, the filemanage ...

What is the best way to hide the button when a user is viewing their own profile in an Angular application?

Each user has their own profile on the platform. A unique feature allows users to send messages by clicking a button when viewing other profiles. However, an issue arises where this messaging button also appears on a user's own profile. Is there a way ...

Execute a standalone haml page within a local rails application

Currently engaged in development of a Rails application, I find myself facing the challenge of updating outdated pages from a common library that is integrated into the app via a gem. These pages are rendered in Haml using YAML files. My task at hand invo ...

Adjusting table column widths in Bootstrap 4

I am completely new to bootstrap and am in the process of enhancing an existing MVC web application that is already utilizing bootstrap 4. My goal is to incorporate a table with form fields, but I am facing difficulties in controlling the column widths of ...

Why does Javascript not manipulate the element arraylist upon reaching it?

I'm facing a challenge with playing audio in a random order after reaching a certain index. My goal is to have the program play audio sequentially starting at index 0 (after clicking a button). Once the index reaches 4, it should still play the elemen ...

Tips on how to ensure a JAVA application opens a webpage in a designated browser

Adding the microsoft-edge prefix to a URL (microsoft-edge:) will open the page in Edge, regardless of the browser being used for running the app. I am wondering if there is an equivalent prefix for Chrome and Firefox? Thank you in advance. ...

What is the best method to add a background image to a short div element?

For instance, here is some example HTML code: <div id="container_background"> <div id="content"> <p> #container </p> </div> </div> This is the CSS code that applies to the above HTML ...

Icons on Google Calendar events - Mini images beside your schedule

I'm in the process of developing a website where I plan to integrate Google Calendar. I want to include a small icon next to specific events to denote certain details. While the "categories" feature in Google Calendar allows me to assign highlight col ...

How can I apply styling to a hyperlink that links to a specific anchor in HTML?

I’m currently dealing with anchor links positioned at the top of my page that navigate to scroll-out infoboxes located at the bottom. When a user clicks on one of these anchors, it directs them to the corresponding box below; however, I also want these b ...

Using Laravel and Bootstrap v4, you can easily implement a feature that redirects to a specific tab after

I have a webpage featuring 3 tabs. I am trying to set up the page so that it redirects to the same tab that was active before the reload. I assume each tab should append a string to the URL, like #menu1 or #menu2, but I'm having trouble implementing t ...

The Next.js application is unable to load the combined CSS from a React Component Toolkit

My React components repository includes individual .css files for each component which are imported into the respective components. These components are then bundled using a rollup configuration and published as an NPM package, with all component CSS being ...

My attempts to integrate PHP into jQuery tabs have been unsuccessful

My code seems to be acting strangely, as the PHP code I originally entered in tab 2 has somehow escaped that tab and spread into all the other tabs. This means it is visible in multiple tabs instead of just one. The purpose of this PHP code is to retrieve ...

What's the scoop with for loops and grabbing elements?

In my code, I have a for loop that looks like this: for(i=0; i<6; i++) { if(i = 0) {a1 = '<div>something1</div>';} if(i >= 1 & i <= 5) {b1 = '<div>something2</div>';} } document.getElementById(&apos ...

Television Mount for Precise Video Placement

Seeking assistance for a unique positioning challenge I am facing. I have a Video that needs to be placed on the home page with a TV-like image "frame" around it, and they should scale together. https://i.sstatic.net/2pLhi.png What I've attempted i ...

Improve loading speed of thumbnail and full images in HTML

I'm struggling with slow loading images on my blog website. Can anyone help me figure out how to improve loading speed and: Is it possible to use a separate thumbnail image that is smaller in size instead of the full image for both thumbnails and th ...

I utilized the `<script src="sample.pdf"></script>` tag in my HTML code and surprisingly, the JavaScript within the PDF document was still able to execute

Recently, I encountered a situation where I included a PDF file with JavaScript code in the src attribute of a script tag in my code. Surprisingly, the JavaScript code executed without any issues. This made me wonder if I can use any type of file extension ...

Troubleshooting Django: Missing CSS File Issue

I spent a considerable amount of time trying to resolve the issue with loading all my static files. Eventually, I found a solution that allowed SVGs to load properly, but my CSS files were still not loading. Below are snippets from my settings.py file (sh ...

Maintain the markup created by jQuery inside the AJAX function called by setInterval

In the code snippet below, real-time markup is generated and automatically updates using the setInterval function. The markup includes buttons and hidden content within div elements. Each button reveals its corresponding div, but the div reverts to a hid ...

Show a loading spinner with a smooth transition effect

After incorporating a loading circle template, I noticed that the circle abruptly appears when the submit button is clicked. I want to achieve a smoother transition for this loading circle. I attempted to use transitions, but it didn't have the desire ...

JavaScript and jQuery are lightning fast, especially when the page is reloaded

I am currently working on a responsive website that uses liquid layouts. I have encountered challenges when incorporating images in the design, especially when dealing with different browsers like IE, Firefox, and Chrome. Recently, I faced another issue w ...