Can the Foundation 5 class label.inline be exclusively utilized for @media medium-up conditions?

I am attempting to achieve a specific layout for various media types, as shown below.

On smaller screens:

+----------------------+
| LABEL                |
+----------------------+
| TEXT INPUT           |
+----------------------+

On medium and larger screens:

+----------------------+----------------------+
| LABEL                | TEXT INPUT           |
+----------------------+----------------------+

Currently, my code looks like this:

<div class="row">
    <div class="columns medium-2">
        <label>
            Label
        </label>
    </div>
    <div class="columns medium-10">
        <input type="text" />
    </div>                                    
</div>

However, on medium and larger screens, the label is not vertically aligned in the middle or horizontally aligned to the right. Foundation 5 provides special classes label.inline and label.right, but I prefer not to use these on smaller screens.

An option I am aware of involves using two labels - one visible only on small screens and the other visible on medium and larger screens with additional classes:

<label class="visible-for-small-only">
    Label
</label>
<label class="visible-for-medium-up right inline">
    Label
</label>

Is there a CSS-only solution that allows me to utilize Foundation classes inline and right while avoiding the need for two separate labels?

Answer №1

If you are using SASS, you have the ability to create a custom class that includes inline label styling for medium screens and larger. Here is an example of how you can achieve this:

label {
    &.inline-for-medium-up { 
        @media #{$medium} {
            @include form-label(inline,false);
        }
    }
}


<div class="row">
    <div class="medium-2 columns">
        <label class="inline-for-medium-up">
            Label
        </label>
    </div>
    <div class="medium-10 columns">
        <input type="text" />
    </div>                                    
</div>

A brief explanation:

Using SASS allows you to create mixins containing CSS styles that can be easily included throughout your project. The `form-label` mixin provided by Foundation encompasses all necessary form label styles. You can add parameters to the mixin, such as "inline". By including the mixin with the "inline" parameter within a media query set for medium-sized screens or larger, you ensure that only those specific styles will apply when needed.

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

Challenges with line height in IE when adjusting font size in textarea

I'm facing an issue with adjusting the font size in a textarea using JavaScript. While it works perfectly in Firefox, there are some problems in IE. Specifically, the line-height does not change accordingly. This results in gaps between lines when the ...

Is it possible to employ a method to eliminate a specific valuable element 'this' from an array?

I am working on a task management app that allows users to create a To-Do list and remove specific items from the list. Currently, I am facing an issue with using 'localStorage' to save the list when the page is refreshed. The problem arises when ...

Learn the technique for showcasing numerous markers on Google Maps, each equipped with its own individualized info windows

https://i.sstatic.net/1tTUD.png // map center var center = new google.maps.LatLng(2.855262784366583, 105.4302978515625); function initialize() { var mapOptions = { center: center, zoom: 7, mapTypeId: google.maps.MapTypeId.ROADMAP }; // Create a < ...

Tips for excluding two attributes when styling a CSS calendar selection

Let's say I have a table structured like this: <td class="search-unit-custom-control-calendar-day search-unit-custom-control-calendar-day--not-this-month"> <time class="search-unit-custom-control-calendar-day__number">--</time> ...

Image set as the background on a website

I recently started working with Groovy and Grails, designing my own personal website. I'm looking to set an image (located in the asset folder) as the background for my index.gsp page. How can I achieve this? ...

jQuery not functioning properly for adjusting quantities with plus and minus buttons

Hey there, I've been trying to create a number input increment using jQuery but haven't had any luck so far. Could you please take a look at my code and provide some guidance? CHECK OUT THE DEMO HERE Here's the HTML: <div class="sp-qua ...

Display tooltips on top of z-index stacking contexts

I am struggling to display a tooltip within a table field, on top of other fields and tables. The issue lies in the fact that the other tables and elements are housed within different DIVs that have set the CSS z-index property to 0. Even if I assign a hi ...

Place a PNG image within a div container carousel

Despite my efforts, I have been unable to find an example of what I am trying to achieve. I have a carousel and my goal is to insert a PNG image into the carousel in such a way that it slightly exceeds the top of the div like this: https://i.sstatic.net/M ...

The search bar is visible on desktop screens and can be expanded on mobile devices

Check out my code snippet below. <style> #searchformfix { width: 50%; border-right: 1px solid #E5E5E5; border-left: 1px solid #E5E5E5; position: relative; background: #fff; height: 40px; display: inline-block; border: ...

What is the best way to dynamically display CSS code from a PHP variable without needing to refresh the

I am working on a page that utilizes ajax and PHP for all functions. Within the tab content, users have the option to select colors using color pickers. Once a user saves their chosen colors, I store the new CSS code in the database. The CSS code is as ...

When a radio button is clicked in Angular7 and it shares the same form control name, both radio buttons are being

Visit this StackBlitz link for more information. places = ['effil tower','new discover'] new FormGroup({place: new FormControl()}); <div *ngIf="places?.length > 0" class="col-12"> <div style=" padding-top: 1e ...

Apply a 2 pixel top border to an HTML table

Is there a way to add a double border at the headcell without using background images? Currently, I have a white color border top and want to add a grey color border on top of the white one. Is it possible to achieve something like #ccc and #fff for borde ...

Broadcast live video on your website using VLC/Red5 or any other streaming platform of your choice

Currently, my home website is built using Java/SpringMVC web server. I am looking for a way to stream my webcam feed on my website so I can access it from any browser and see the live view of my room. If anyone has recommendations for an easy-to-use solut ...

Tips for utilizing data-target in the URL

Is it possible to use data-target as a URL, such as in login.php, where data-target = "#sign-up" and then add sign-up to the URL using header('Locations: login.php#sign-up');? I attempted this, but it seems to not be functioning as expected. ...

What is the best way to include a div element with a dynamic animation on a webpage?

I'm attempting to create a laser beam that can shoot enemies on the screen, much like in classic games such as Space Invaders or Galaga. However, I am encountering difficulties getting the laser to move when I click the button. Below is the code I hav ...

The appearance of Google charts' X-axis leaves something to be desired

I used the google charts API to create a chart, but I am facing an issue with the X-axis labels. When I have multiple strings on the X-axis, the labels do not look good. I suspect that the problem lies in the X column type being a string instead of DATETIM ...

Guide on leveraging npm start to compile ES6 React components and Foundation Sass

Following a tutorial on setting up a React project, everything seemed to be working perfectly after installation. However, I now need to incorporate Foundation as the front-end library for a website. The issue arises because the tutorial's server.js ...

Is there a method to ensure that flex children adhere to a minimum height, while still permitting them to exceed the height of their container?

This code snippet sets up a CSS layout where child elements within a container have dynamic heights. The issue arises when the contents of #child-2 spill over into #child-3, even though min-height: 100% is set on #child-2. It seems that #child-2 won't ...

Quiz results are incorrect

I've been working on creating a quiz application using JavaScript only, but I'm encountering an issue with the scoring. Initially, I set the correct variable to 0 and intended to increment it by 1 each time a correct answer is selected. However, ...

Using JavaScript, learn how to dynamically add a `<select class="form-control">` in Bootstrap

Currently delving into the realms of Bootstrap and jQuery, these are both new territories for me. I am looking to use JavaScript to dynamically create the <select class="form-control"> tag. In my JavaScript code snippet, I have this: var response ...