What could be causing the button to act like a block element?

How come the button is acting like a block element even though it should be a block-inline element? The input tag is also inline, so according to Bootstrap 4, they should appear next to each other horizontally. However, in the code below, the elements are displaying on top of one another.

<button type="button" style="display: inline" class="btn btn-primary">C</button>
<input type="text" style="display: inline" class="form-control" placeholder="Username" aria-describedby="basic-addon1">

Answer №1

.form-control has a

width of 100%.</p>

<p><div>
<div>
<pre><code><link href="https://maxcdn.bootstrapcdn.com/bootstrap/4.0.0-alpha.6/css/bootstrap.min.css" rel="stylesheet"/>
<button type="button" style="display: inline" class="btn btn-primary">C</button> 
<input type="text" style="display: inline" class="form-control" placeholder="Username" aria-describedby="basic-addon1">

Answer №2

Using the grid layout structure of Bootstraps concept, simply grouping them together will ensure that it works seamlessly and scales properly to utilize available space efficiently (particularly width in this case).

<link href="https://maxcdn.bootstrapcdn.com/bootstrap/4.0.0-alpha.6/css/bootstrap.min.css" rel="stylesheet"/>

<div class="input-group">
  <span class="input-group-btn">
    <button type="button" class="btn btn-primary">C</button> 
  </span>
  <input type="text" class="form-control" placeholder="Username" aria-describedby="basic-addon1">
</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

Use HTML5 to implement canvas dragging functionality

My project involves a large HTML5 Canvas that I need to function similar to Google Maps: the ability for users to drag it and view only a portion of it (equal to the screen size) at any given time. The canvas should render only the visible portion on the ...

animation of leaping to a specific element

I am currently working on a sidebar with links that have a hover effect to add a bullet. However, I want the bullet to smoothly follow the cursor's movement along the y-axis within the sidebar instead of jumping between the links. How can I achieve th ...

Tips for incorporating additional filter criteria into a jquery script

I am currently utilizing a jQuery script to filter data based on date periods. However, I now need to include an additional filtering criteria for the "POSITION" column. Since I lack expertise in jQuery, I would rather accomplish this using plain vanilla J ...

Tips for utilizing the .clone() method within a loop or for each individual element of an array

Due to certain requirements, I find myself in a situation where I need to customize the invoice template within the software I use. The invoices are generated in HTML format, prompting me to consider utilizing Stylish and Grease Monkey for this task since ...

Can you explain the significance of the `?` symbol before an object attribute? And why is my TypeScript file not recognizing it?

I have always utilized this particular behavior in Angular using the *ngIf directive when dealing with an object that could potentially be undefined or not the required object. <div *ngIf="object?.foo"> ... </div> Although I know that this ...

What is the best way to keep an image fixed at the top while scrolling, but have it disappear when the page reaches the footer?

I am in need of creating a unique Bootstrap 4 layout that involves an image staying fixed to the top after scrolling down until it reaches the bottom of the header. When the page is further scrolled down and the footer comes into view, the image should sta ...

Tips for customizing the appearance of the React Native side menu

After successfully implementing a side menu using react native, I am now looking to style the image to match the design shown in the links below: Check out the application I developed I want it to look like this Is styling the key to achieving this desi ...

Tips for showing tooltip above all else

Having an issue with the tooltip not displaying correctly. Tried adjusting the z-index with no success. Styling in CSS: a.tooltipA { outline:none; } a.tooltipA strong { line-height:30px; } a.tooltipA:hover { text-decoration:none; } a.tool ...

What is the best way to bring a background image to the forefront?

I am currently working on creating a list of "fake videos" which are essentially images with a play icon on them. My plan is to use the play icon as a background and bring it to the front of the image by adjusting the z-index. However, no matter what I try ...

Grab all the text using Java Jsoup

I am having an issue with the code I have written. The doc.body.text() statement is not displaying the text content within the style and script tags. I examined the .text() function code and found that it searches for all instances of TextNode. Can someone ...

Is there a way to extract the code from the "View Page Source" option on a website using BeautifulSoup or a different library?

While perusing the website, we are given the choice to "View source" and "View page source". BS4 allows us to extract data from the "View page source", but is it feasible to extract data from the "View source"? If not, what alternative methods can be use ...

Exploring the possibilities of LimeJS HTML5 through the integration of various

Is it feasible to utilize various libraries such as Node.JS, JQuery, and LimeJS together without any limitations? ...

Changing Background Images Based on Screen Size in CSS Media Queries

Hey there, I am currently using two different header images - one for desktop and another for both tablet and mobile devices. I am wondering how I can automatically switch from the desktop header image to the mobile/tablet header image when the screen siz ...

In jQuery, how to create a single event that applies to two different elements simultaneously, rather than individually for each element

How can I create a toggle event for 2 different TDs within my table row that will show/hide the next table row when clicked? <table> <tr> <td>1</td> <td>2</td> <td>3</td> <td>4</td> & ...

Failing to draw an image on a blank canvas

I'm having trouble with my canvas. I want to clear it and then redraw it 30 pixels to the left on the x axis. However, when I try running the code, the canvas clears but the new image is not drawn. If I remove the "clearRect" function, the images are ...

The v-for directive is displaying my list in a single row with multiple columns instead of in a single column with multiple rows

Can someone please assist in rendering my list as shown below: A B C The current rendering looks like this: 1: A 2: B 3: C Below is the code snippet: To-Do List: <input type="text" class = "todo" placeholder = "Next Item" v-on:keyup.enter="add ...

Using Javascript, dynamically animate the text in the hero unit with fading in and out effects

I currently have a "Hero" unit with the following code: <div class="hero-unit"> <div class="container"> <h1>Dapibus Euismod Mollis</h1> <p>Aenean eu leo quam. Pellentesque ornare sem lacinia quam venenatis ...

What causes jquery-ui resizable to set the width of the div with the "alsoResize" property?

I have created a series of divs structured like this: <div id="body_container"> <div id="top_body"> </div> <div id="bottom_body"> </div> </div> Additionally, I have implemented the following funct ...

"Ascend beyond the constraints of fixed measurements with dynamic

My JQuery image fader has a width of 100% and height set to auto. I'm thrilled that it works perfectly on the iPhone as well. Now, I am facing a challenge while trying to make content "float" after my JQuery slider. The problem arises because I use ...

Adjusting the slider with jQuery and CSS to extend beyond 100% while remaining within the div boundaries

Currently, I'm working on customizing a jQuery slider. My goal is to achieve the same functionality as the jQuery UI slider where you can set a max value like "2500" and the slider will smoothly adjust without going outside of the specified div or scr ...