Buttons are not aligned with the rest of the row's height

I'm currently working on designing an upload layout that consists of a container with a row inside. Within the row, there are two buttons (each containing input elements) and one h3. For some reason, I am having difficulty getting them to align at the same height consistently. Here is the snippet of code showcasing this issue:

HTML

<div id="mi-wrap">
    <h1>Title</h1>

    <div id="main-wrap">
        <div id="inner-wrap">
            <div id="wide-bar">
                <button id="upload-button">
                <input type="file" id="upload" value="PDF"/>
                </button>
                <h3 id="file-preview"><i class="fa fa-arrow-left"></i>Upload your file here</h3>
                <button id="send-button" type="submit" name="search-button">
                </button>
            </div>
        </div>
    </div>
</div>

CSS:

#mi-wrap {
  width:100%;
  margin:0 auto 0;
  height:200px;
}

#main-wrap {
    background-color:blue;
    width:90%;
    margin:0 auto 0;
    height:100%;
}

#inner-wrap {
  width:100%;
  height:100%;
  display:table;
}

#wide-bar {
    height:60px;
}

#wide-bar button, #wide-bar h3 {
  background-color: green;
  height:60px;
  display:inline-block;
}

#wide-bar button {
  width:25px;
}

#wide-bar button input {
  display:none;
}

#wide-bar h3 {
  width:50%;
}

This code snippet may not be exact but it visually represents the challenge I am facing in my project. You can also check out the corresponding jsFiddle link here.

Answer №1

To achieve the desired layout, consider adding another display property such as inline-block in conjunction with vertical-align

#wide-bar h3 {
  width:50%;
  display: inline-block;
  vertical-align:top;
}

Check out the functioning solution here:

https://jsfiddle.net/56g67abc/2/

Answer №2

give this method a shot

#wide-bar button, #wide-bar h3 {
    background-color: purple;
    border: 2px solid black;
    /*display: block;*/ /*Replace this line with comments*/
    float: right;/*Include this line*/
    height: 50px;
    margin: 5px;
    padding: 10px;
}

Answer №3

Here is a solution that should work:

#wide-bar {
    vertical-align: middle;
    max-height:60px;
    display:table;
}

#wide-bar button, #wide-bar h3 {
  margin:0;
  padding:0;
  background-color: green;
  display:table-cell
}

#wide-bar button {
  width:25px;
  height: 60px;
}

Answer №4

Update your CSS with the following changes:

#wide-bar {
    height: 60px;
}

#wide-bar button, #wide-bar h3 {
    margin: 0;
    padding: 0;
    background-color: green;
    height: 60px;
    display: inline-block;
    float: left;
}

Check out the JSFiddle demo here!

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

Disable the ability to close the dialog box by clicking

this is my dialog <div *ngIf="visible" class="overlay" (click)="close()"> <div role="dialog" class="overlay-content"> <div class="modal-dialog" (click)="$event.stopPropagation()"> <!-- Modal content--> ...

Adjustments made to the size of the h1 font

I am perplexed by the fact that these two h1 tags have different font sizes, even though they have identical properties and declarations. From what little knowledge I have, it seems like it may be related to inheritance; considering one h1 tag is nested an ...

Tips for choosing the most current or upcoming item from a list using buttons

I am currently working on a small website project for one of my lessons. The task involves selecting items from a list and using two arrows to navigate to the item above or below the current selection. Here is an example: https://i.stack.imgur.com/FxZCN. ...

Interactive CSS Video Gallery Slideshow

Is there a way to create a slideshow video gallery using CSS? I've looked everywhere but all I find are slideshow image galleries. If anyone has any resources or tips on how to do this, please share! This is the kind of video gallery I'm looking ...

Utilize text wrapping to ensure a fixed maximum height for content display

I am in need of a div that contains text spanning multiple lines, with both a fixed width and a maximum height. Currently, I have applied the CSS property overflow: hidden;. However, my issue arises when the last line of text exceeds the maximum height of ...

On a Samsung tablet with Moodle, the body background image is set to display at the top

Encountered an issue with Sambungs tables. I have a background image set on the body. Here is how the CSS looks: html, body{ background: url('img/background.jpg') no-repeat; background-position: top; // I also tried cover, fixed, etc } The ...

Ways to incorporate a reverse transition effect

I am encountering an issue with a sliding effect on a div. When it has a class hddn, the overlay will have right: -100% from the viewport. However, when the hddn class is removed, it should return to the viewport with right: 0. How can I animate this movem ...

"Enhance your HTML table by selecting and copying cell values with a simple click and CTRL +

I stumbled upon a fantastic script for highlighting HTML table rows and it's working perfectly: I decided to modify the onclick event to onmouseover and included additional code to select a cell by clicking on it. Now I can select, check which one is ...

Ensuring a @keyframe animation remains constant for the entire duration of the user's visit to the webpage using CSS

How can I create a continuous @keyframe animation that stays active for the duration of the user's visit to my webpage? I've implemented several color animations on my website, each with a specific duration. Is there a way to make these color ch ...

To prevent flickering when using child flex elements, it's best to use position fixed along with a dynamically updated scrollbar position using Javascript

My navigation component includes a slim banner that should hide upon scroll and a main-nav bar that should stick to the top of the screen and shrink when it does so. I initially looked into using Intersection Observer based on a popular answer found here: ...

Why won't my Java servlet code execute?

included the directory structure To facilitate adding two numbers and displaying the result upon clicking a submit button, I developed a straightforward Java servlet. This servlet retrieves the necessary information when called. The development environmen ...

The input field is failing to show up on the screen

I have been working on my React app and experimenting with how to dynamically display input elements based on different screen sizes. To achieve this, I implemented the use of window.innerWidth as shown in the code snippet below: <div className='Tr ...

Move your cursor over one container to see the impact on another

My goal is to create a hover effect on a box that triggers another div with easing effects. Below, you'll see that the .images{} class has a 0s infinite scroll initially, but when the .box:hover > .images{} selector is activated, it changes to a 10 ...

Having trouble integrating the css and js animation files into my Django project

settings.py import os BASE_DIR = os.path.dirname(os.path.dirname(os.path.abspath(__file__))) SECRET_KEY = '@6qt%i+0&_=z0#zl^+!u3bw6c7dmg4e3khboj%7s7439z9#ky(' DEBUG = True ALLOWED_HOSTS = [] INSTALLED_APPS = [ 'django.contrib.admin& ...

focusing on two different sections with a single hover effect

Is it possible to modify the styles of two different divs using CSS when hovering over one div? #down-icn { position: absolute; bottom: 0; right: 25px; color: #fff; -webkit-transition: color 0.25s ease; border-color 0.5s ease; -moz-transition: colo ...

CSS: Handling Background Images Responsively

I'm experiencing an unusual issue where the image is not appearing, even though the div box shows up when I highlight elements on the page. Validation and inspection also show no issues. Here is the code: <div class="mainImage"></div> A ...

Navigating without the need for a mouse click

Is there a way to automatically redirect without user interaction? I need the redirection to happen without clicking on anything <script> setInterval(function(){ window.location.replace("http://your.next.page/"); }, 5000); // Redirec ...

The project is experiencing difficulties in loading the Module CSS

Currently, I am working on a React module and have set up a React project to demonstrate the functionality of this module. Initially, everything was working smoothly until I encountered an issue with the webpack configuration related to the CSS loader. { ...

Designs for an HTML5 Cheeseburger navigation interface

I've been struggling to implement a functional and visually appealing hamburger menu on my website. The challenge lies in integrating the menu seamlessly into the page rather than having it just pop up abruptly. Despite trying various webkit tools, I ...

I have implemented a custom-built sidebar component and I'm unsure about the process of adding data to it

After successfully incorporating this SideBar into my Vuex/Laravel project, I encountered a problem. The example code provided used: <div :class="$style.sidebar"/> However, when I tried to modify it to: <div :class="$style.sidebar">Content&l ...