What is the best way to position a full width input beside my div element?

Having a small challenge with my CSS/HTML code, I am trying to position a full-width input next to my div.

This is my HTML :

<div class="leftdiv"></div>
<input type="text" id="title-input" placeholder="nothing"></div>

And here is the CSS :

.leftdiv {
    height: 60px;
    float: left;
    background-color: aqua;
    width: 60px;
}
#title-input {
    width: 100%;
    height: 60px;
}

I need the "leftdiv" to be exactly 60px x 60px, so I'm unsure if using Bootstrap's row would work for this case.

Answer №1

Utilizing Flexbox for this task is the way to go:

* {
  -webkit-box-sizing: border-box;
  -moz-box-sizing: border-box;
  box-sizing: border-box;
}
.wrap {
  display: flex;
}
.leftdiv {
  height: 60px;
  background-color: aqua;
  width: 60px;
}
#title-input {
  flex: 1;
  height: 60px;
}
<div class="wrap">
  <div class="leftdiv"></div>
  <input type="text" id="title-input" placeholder="nothing" />
</div>

Answer №2

Your error lies in prematurely closing the </div> tag right after opening it. Make sure to keep it open before ending it.

Here is the correct structure:

<div class="leftdiv">
  <input type="text" id="title-input" placeholder="nothing">
</div> 

Check out this link for reference.

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

Is there a method to make an <img> automatically adjust its width to fit that of its containing <div> even if the style/attributes are

If I'm unable to customize the style, tag, or attributes of an image element, is there a way to make its width adjust to fit a parent division or another container? This situation pertains to an email template, so external stylesheets, <style> ...

Removing parent elements with JQuery

I have a piece of third-party HTML that I need to work with: <tr> <td> <asp:Label ID="lblURL" AssociatedControlID="txtURL" runat="server" EnableViewState="false" CssClass="FieldLabel" /> ...

Utilize the JMX HTML adapter in conjunction with Apache Camel's JMX capabilities

I'm currently utilizing the Sun HTML JMX Adapter to display Camel's exposed JMX beans in an HTML format. I've been working with Spring XML to achieve this, but I'm struggling to establish a connection between the adapter and the JMX age ...

When hovering over an image, another image is revealed

<div> <a href="#"><img src="images/Informasjon_button.png" width="120px" height="120px" /></a> </div> <div> <a href="#"><img src="images/Mail_button.png" width="120px" height="120px" /></a> </div ...

Explanation: The information box does not appear when the mouse hovers over it

Welcome to the gallery showcasing a unique calendar design with tooltip functionality. This calendar features a special hover effect for New Year's Day on January 1st, displaying a tooltip text upon interaction. Feel free to explore the code below to ...

html div elements may not align correctly

Currently, I am in the process of coding a website that contains numerous images. To assist me in organizing and arranging these images, I have turned to angularjs. Initially, everything was progressing smoothly until this issue arose: https://i.sstatic. ...

Tick the box to activate the ability to uncheck multiple boxes when there are already a certain number of boxes checked

I am currently developing a multiple-choice form in my MVC5 app and I am struggling to find a way to disable unchecked boxes once a specific number of boxes have been checked. For example, if 3 out of 5 boxes are checked, the remaining 2 should be disabled ...

Error with Bootstrap 4 tabs and JavaScript AJAX implementation

I have implemented Bootstrap 4 tabs to showcase content fetched through an AJAX call. However, I encountered an issue upon completion of the call. The error message displayed is: Uncaught TypeError: $(...).tab is not a function The tabs are initially hi ...

When I engage with the input field, it ceases to be in focus

Here is the code I've been working on: https://github.com/Michael-Liendo/url-shortener/blob/main/src/pages/index.js If you want to see the issue for yourself, check it out at: ...

The popover box adjusts its width to fit the contents in Chrome, however, it does not do so in

Having issues with the container width in Edge compared to Chrome despite the Sass code working fine in Chrome. Here's the code: .popover { font-family: 'Tahoma', sans-serif; max-width: 100%; box-shadow: 0 0 15px 6px #646262; ...

Issues arise when the sub-menu does not function properly and overlaps with other elements of

I've been working with a client on their website and encountered an issue. On the mobile version of our menu, when I hover over a menu item that has several sub-menu items, those items display properly, but there is an element below them showing thro ...

Link the ng-model to an asynchronous function for fetching and updating data

After struggling with my previous attempt to solve a question, I have decided to present it here without any prior attempts. (You can view my previous topic here: ng-model to async xhr get/set field on my server ) Working with angular in a browser addon, ...

What is the most effective way to retrieve the inner HTML of an HTML tag using JavaScript or jQuery?

Let's consider the following code snippet: <p class="question"> this is my paragraph <p> And i'm inside tag in question class <h1> And this is my heading</h1> </p> </p> Now, the challenge is t ...

Stop menu items from shifting when focused

I've developed a mobile hamburger menu and attempted to adjust the padding to create space between the text and the borders. Here's the HTML: #menu-solutions:hover .menu-item-text, #menu-solutions:focus .menu-item-text, #menu-solutions:ac ...

Arranging an image and button within a column div row using Bootstrap

I'm encountering an issue with Bootstrap where I am trying to align the blue buttons neatly below the image. Link to the image: img Here is a visual representation: https://i.sstatic.net/tB5mU.png This is the code snippet: <div class="row&q ...

What is the reason behind using <script> tag for scripts, instead of using <style> tag for external CSS files?

A family member who is new to Web Development posed an interesting question to me. Why do we use <script src="min.js"></script> and <link rel="stylesheet" href="min.css">? Why not simply use <style href="min.css"></style>? Wh ...

Optimizing VueJS applications with browser caching features for faster loading

I've encountered an issue with my VueJS app. After running npm run build, a new set of dist/* files are generated. However, when I upload them to the server (replacing the old build) and try to access the page in the browser, it seems to be loading th ...

To implement a class based on a media query, only pure CSS or HTML is required

Is there a way to apply a specific class to an ID based on screen height using only CSS, HTML, or LESS without pre-compilation? The goal is to set classes from Add2Any, not CSS properties. Here is a link to the jsfiddle. The desired outcome is to have th ...

Embed an audio file onto a webpage

Is there a way to add an audio file to my website if I only have the .mp3 version and not the .ogg one? When I try to play the audio, it doesn't work. Can someone help me with this issue? Here is the code I am currently using: <audio controls auto ...

What is causing the failure of these "span" elements within an "a" tag in IE7?

Here is a code snippet that I am working with: HTML (version 4.0) <div class="temperatura"> <a href="/link/" class="temperatura_localita"> <span style="padding-left:12px;"> T ...