Assign a class name to the ::-webkit selector

Looking for a way to add a classname for webkit, moz, and ms. How do I convert the following:

::-webkit-input-placeholder {
    text-align: center;
}

::-moz-placeholder { 
    text-align: center; 
}

::-ms-input-placeholder { 
    text-align: center;
}

to:

.form-horizontal {

::-webkit-input-placeholder {
    text-align: center;
}

::-moz-placeholder { 
    text-align: center; 
}

::-ms-input-placeholder { 
    text-align: center;
}

}

Thank you.

Answer №1

To apply a specific class name to your selector, simply add it before the selector. For nested selectors like this, consider using a preprocessor for easier management.

.form-horizontal ::-webkit-input-placeholder {
    text-align: center;
}

.form-horizontal ::-moz-placeholder { 
    text-align: center; 
}

.form-horizontal ::-ms-input-placeholder { 
    text-align: center;
}
<div class="form-horizontal">
  <input type="text" placeholder="centered">
</div>

<div>
  <input type="text" placeholder="non centered">
</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 are the best ways to create image animations on top of other images using CSS or JavaScript?

Imagine if the first image is in black and white, while the second one is colored. How can we make the black and white image change to color after a timeout period, with an animation similar to loading progress bars? Is this achievable using CSS or JavaScr ...

REACT: Implement a feature to add a distinctive border around the currently selected image

When selecting a picture, I would like to have a border around it. Specifically, if out of 6 pictures I choose 3, I want highlighted borders around those selected images. How can this be achieved? EDIT: I am utilizing React to address this issue. ...

Troubleshooting Autocomplete User Interface Problems

I am currently working on a website user interface and I have encountered an issue specifically in IE7. When searching for a company, the display is not showing up correctly, as demonstrated in the image below. This problem only occurs in IE7, it works fi ...

The integration of a Bootstrap modal within the side bar's rendering

Struggling with a modal appearing inside my side div and can't find any solutions in the bootstrap5 documentation or online forums. https://i.stack.imgur.com/gHsBi.png I just want the modal to display centered on the page with the background fade ef ...

Step-by-step guide on achieving a radiant glow effect using React Native

I am looking to add a glowing animation effect to both my button and image elements in React Native. Is there a specific animation technique or library that can help achieve this effect? While I have this CSS style for the glow effect, I am uncertain if ...

How can jQuery select an element by its id attribute by referencing the href attribute of a different element?

Whenever the user interacts with a div.nav element, jQuery switches its class to active. Presently, it applies display: block to all three of the div.content elements. I aim for jQuery to only apply the display: block property to the div.content elements t ...

When CSS is applied, the canvas is stretched, whereas it remains normal when `width` and `height` attributes are used

I own two canvases, one is sized using HTML attributes width and height, while the other is sized using CSS: <canvas id="canvas1" width="300" height="300" onmousedown="canvasClick(this.id);"></canvas> < ...

Is there a way to modify Style Properties in JavaScript by targeting elements with a specific class name using document.getElementsByClassName("Class_Name")?

I am seeking a solution to change the background color of multiple div boxes with the class name "flex-items" using JavaScript. Below is my current code: function changeColor(){ document.getElementsByClassName("flex-items").style.backgroundColor = "bl ...

Unique background image that perfectly aligns with the dimensions of a single full screen

Does anyone know how this webpage achieves the effect of having a full-screen background that ends when scrolling down? I have noticed that the picture of the desert always covers my entire browser screen but is not a typical full-screen background as it ...

Modify the css based on the user's input

<html lang="en"> <head> <link rel="stylesheet" href="style.css" /> <li id="visa"> <section class="credit-card visa gr-visa"> <div class="logo">visa</div> <form> <h2>Payment ...

Steps to set a background image for an entire page in VueJS

I recently downloaded a Background Image to add to the Home Page of my VueJS application. Unfortunately, when the page loads, only a portion of the page is covered by the image. My goal is to have the entire page filled with the image, except for the Navba ...

Struggling to make images wrap properly using flexbox

I've been struggling to get these images to wrap properly within my container. They keep overflowing beyond the designated width and I'm not sure if it's because I have paragraphs placed under each image. Any ideas on how to make 3 images ap ...

Alignment customization for Bootstrap 4 dropdown menus

I'm currently working on creating a unique custom drop-down menu design. I had an initial idea in mind which looked like this: https://i.sstatic.net/CFqdi.png However, the final outcome turned out like this: https://i.sstatic.net/je21s.png I' ...

Show an HTML email message on a webpage without disrupting the existing page layout

Looking for a solution to display mail messages on a web page originating from an exchange server with various style elements that might interfere with the existing page layout. Attempting to load these mail messages within a div results in the style elem ...

Personalize Drop-Down Selection

Currently implementing bootstrap on a site and seeking to enhance the dropdown menu customization. The default navbar appearance is present, with dropdown elements appearing upon hover. My goal is to include an icon next to each item in the navbar and ha ...

Spinning html/css content using JavaScript

Greetings! I am currently working on a demo site using just HTML, CSS, and JavaScript. Typically, I would use Ruby and render partials to handle this issue, but I wanted to challenge myself with JavaScript practice. So far, I have created a code block that ...

Design a sleek and modern form using Bootstrap 4 that mirrors the aesthetics of the forms found in Bootstrap 3

Is there a way to create a form using BootStrap 4 that resembles the easily customizable forms from BootStrap 3? I am looking to have a bold, right-aligned label within a specific column size (e.g. col-sm-4), with an input field next to it whose width is c ...

Tips for implementing an autoscroll feature in the comments section when there is an abundance of comments

Having a large number of comments on a single post can make my page heavy and long sometimes. This is the current layout of my post comment system: Post 1 Comment for post 1 //if comments are more than 3 <button class="view_comments" data-id="1">Vi ...

Adjust the size of a div using absolute positioning

Can a div with absolute position be resized? I need this pink modal to maintain the same width as the input and resize accordingly. This modal will be utilized in a dropdown component, so it should resize along with the input. Moreover, is using absolute ...

Achieving full-width container on mobile devices with Bootstrap

Despite my efforts in the CSS file, I am still struggling to get the container to take up the full width on mobile devices. Here is my CSS code: @media (max-device-width: 1024px) { .col-sm-2{ width: 100%; } .container { margin: 0 auto; width: ...