What is the best way to decrease the width of a textfield in jQuery mobile?

Is there a way to decrease the width of a textfield in jQuery mobile?

Check out this Fiddle for reference

The CSS provided below does not seem to be working properly:

#co label{
    color: red !important;
    width: 100px !important;
    margin :30px;
}

#co input{

    width: 100px !important;
    border-radius: 0 !important;
}

Answer №1

 #co .ui-input-text
 {
    width: 100px;
  }

Answer №2

Behold... It's Functional!

HTML Markup

   <div data-role="content" id="co">
      <div data-role="fieldcontain">
         <label >Username</label>
        <input type="text"/>
    </div>

CSS Style

    #co label{
     color: green !important;
     width: 120px !important;
     margin :20px;
     }
   #co .ui-input-text{
   width: 120px;
   border-radius: 60;
 }

Answer №3

Adjusting the size and style of the input box can be done by modifying the CSS properties that define its appearance.

#co div.ui-input-text{
    width: 100px;
}

Test it out on JSFiddle: http://jsfiddle.net/BKbZB/3/


To create a combination of default and small input boxes, you can use the following code:

<div data-role="fieldcontain" class="small-input">
    <label>User Name</label>
    <input type="text" />
</div>

Here is the corresponding CSS code to achieve this:

.small-input div.ui-input-text{
    width: 100px;
    padding: 0px 2px;
}

Try it yourself on JSFiddle: http://jsfiddle.net/BKbZB/5/

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

Animate the jQuery element to fade in after it has been hidden with the slide effect

I am trying to create a div that slides out of the viewport and then fades in at the same spot with a different background image. However, currently it only slides out and does not fadeIn: $('#myDiv').hide('slide').queue(function() { ...

Implementing transfer of datepicker value to another upon selection is not functioning as expected

I currently have the following jQuery script implemented on one of my views: @section Scripts { @Scripts.Render("~/bundles/jqueryval") <script> $(document).ready(function() { getTotal(); setDates(); }); $("#form1").on("input", function () ...

How to troubleshoot WordPress Ajax function not getting form data

I am currently working on a form in my plugin where I need to send data to my AJAX action function using the standard WP Ajax techniques. Here is the basic structure of my form: <form role="form" id="signup_widget_form" method="post" action="#"> ...

Tips for arranging 3 tables in the right place using CSS

I have 3 tables that I utilize. My goal is to: have one on the left side of the page place one in the center of the page position one on the right side All at the same height. The issue arises when the tables expand and using float causes them to ...

The application of border-radius causes the div to extend beyond its intended height

Is there a way to achieve a smooth shadow effect on pictures without it touching the corners? I attempted to do this by adding a border-radius and box-shadow to the parent div of the images, but now the parent div is taller than the picture itself. Any sug ...

Adjust the navigation bar to expand based on the amount of content it contains

I have two pages for my website - a forum and a homepage. While the homepage is all set up, I need to make some modifications to the navigation bar on the forum page. I have mirrored the navigation bar from the homepage to the forum to ensure consistent st ...

"Need help with resolving issues in my React Bootstrap Navbar? Learn the latest updates on fixing Navbar Brand Collapse here

Having issues with my React.js website navbar created using bootstrap. The menu button doesn't show up when the navbar collapses at a certain point. Can someone spot what's missing in the code below? Tried toggling by following a tutorial, but i ...

Modifying content in span element upon click event using jQuery

There is a button placed inside a span element <span class="act-button"><input type="button" value="Deactivate" onclick="deactivateTemplate(' + options.rowId + ')"></span> The requirement is to update the text inside the span. ...

Customizing the active link color in Bootstrap dropdown menus

Is there a way to customize the color and background of an active link in a boostrap's dropdown menu? Despite trying to override bootstrap's @dropdownLinkColorActive and @dropdownLinkBackgroundActive variables, the changes don't seem to tak ...

Manipulate the value(s) of a multi-select form field

How can you effectively manage multiple selections in a form field like the one below and manipulate the selected options? <select class="items" multiple="multiple" size="5"> <option value="apple">apple</option> <option va ...

Is there a way to reset back to the default CSS styles?

I have a div container with a nested span element (simplified). <div class="divDash"> <span>XX</span> </div> The CSS styling for the div makes the span initially hidden and only visible when hovering over the parent div. .div ...

What is the reason that the <script> tag cannot be directly inserted into the .html() method?

As I continue to learn front-end development, I've created my own version of JS Bin. When the 'run' button is clicked, a statement is executed to showcase the HTML, CSS, and JavaScript in an iframe (the output window): ("iframe").contents() ...

Best Practice for Delivering JavaScript Files with Node.js Ajax?

In my current project, I am developing a node application that serves client-side JavaScript code to a static webpage. The goal is to have the code evaluated within the webpage, similar to the concept demonstrated in this example, but using Node.js instead ...

Adding an HTML tag to a div using jQuery

Currently, I am trying to dynamically add a field to my form using the following code: Using JQuery: $('#addField').click(function(){ $('#divTest').append("<html:text property='titles'/> <br> <br>"); }) ...

What is the best way to aggregate a JSON response?

I'm currently in the process of combining a JSON response from a stored procedure. Here is the response as it is from the procedure: [ { "type": "fruit", "name": "apple" }, { "type": "animal", "name": "cat" }, { "type": "fruit", ...

Is it possible to eliminate the css class prefix when using Modular css in React?

When working with React & NextJS, I have observed that my modular SCSS files are automatically prefixing my classnames with the name of the file. Is there a way to turn off this feature as it is making the DOM structure difficult to interpret? For instanc ...

Count of elements in one flexbox row

Having a flexbox container with multiple items in row-wrap format, is there a way to use JavaScript to determine the number of items in each row? Essentially, finding out at what point they wrap. For instance- <div class="container"> <div clas ...

Having trouble with changing images or background images in JavaScript?

Encountering issues with dynamic elements. When I click a button, the following JS function is executed. It displays a stylish CSS alert upon postback and then runs the function. function scrollToTop(sender, args) { window.scrollTo(0, 0); document. ...

The <h1> element is not responding to the style attribute

Exploring HTML as a beginner has led me to an interesting issue. I've been practicing my newfound skills on W3Schools' platform and everything was running smoothly until I encountered a discrepancy in how the code is rendered on Wordpress. The s ...

jscroll loads new data as you reach the bottom

My UI design requires infinite scrolling, so I am utilizing the jscroll plugin. The goal is to load new data when reaching the end of a div. <script src="http://ajax.googleapis.com/ajax/libs/jquery/1.10.2/jquery.min.js"> </script> <script s ...