Centering multiple floated divs using bootstrap

Looking for some help with a bootstrap panel design. I am trying to align a heading title to the left and a select element along with a date range input to the right of the panel heading, vertically aligned in the middle. While I have made progress on this, the issue lies with the vertical alignment of the select item.

https://i.stack.imgur.com/d9hrD.png

If you'd like to take a look at my code on a fiddle, here is the link: https://jsfiddle.net/prxbl/5ca3xo0b/8/

HTML

    <div class="panel panel-default">
      <div class="panel-heading" id="comenzi-chart">
        Heading
        <div class="input-daterange input-group" id="datepicker">
          <input type="text" class="input-sm form-control" name="start" />
          <span class="input-group-addon">to</span>
          <input type="text" class="input-sm form-control" name="end" />
        </div>
        <div class="select-chart-type">
          <select class="form-control">
            <option>Daily</option>
            <option>Weekly</option>
            <option>Monthly</option>
          </select>
        </div>
      </div>
  </div>

CSS

.input-daterange {
    width: 250px;
    bottom: 5px;  
    float: right;
}

.select-chart-type {
    padding-right: 10px;
    float: right;
}

.select-chart-type select {
    padding: 5px 10px;
    height: 30px;
}

I believe there might be a better way to approach this layout. If you have any suggestions on how to achieve the desired result - inserting buttons/selects/inputs in the panel heading, following each other, floating right, and being vertically aligned in the middle - please share your insights!

Thank you!

Answer №1

To achieve the desired outcome, consider implementing the following CSS code:

.select-chart-type {
    padding-right: 10px;
    float: right;
    position: relative;
    bottom: 5px; 
}

For a visual representation and further experimentation, check out this Fiddle.

Answer №2

Make sure to include the following CSS within the ".select-chart-type" class:

.select-chart-type {
  bottom: 5px;
  float: right;
  padding-right: 10px;
  position: relative;
}

Check out the UPDATED DEMO

Answer №3

To adjust the spacing, apply margin-top: -5px; to the .select-chart-type CSS class.

Alternatively,

You can also use position: relative;bottom: 5px; on the same .select-chart-type class for a similar effect.

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

How wide should the website layout be?

What is the perfect size for a standard portal website? I've seen many sites with widths ranging from 960px to 1000px. ...

What is the best way to extract the numerical value from a JavaScript object?

I'm currently working on a web form for a currency exchange demonstration. I have included a snippet of HTML and Javascript code that I have initially implemented. <!DOCTYPE html> <html lang="en"> <head> <meta charset="ut ...

using jquery to select elements based on their data attribute values

I have a question about using jQuery to select an object with a specific data value. For instance: $('[data-infos-parent_id=0]').html('it ok'); <div class="question" data-infos='{"parent_id":0,"my_id":0, "title":""}'> ...

Having trouble getting Sass extending to work in a basic scenario?

Here we have a simple example of Sass code, an Angular 2 component that accesses the Sass code, and the rendered HTML. However, there seems to be an issue with the blueBig span element in the last part. As someone new to Sass, I am not sure why this basic ...

You can only import Next.js Global CSS from your Custom <App> and not from any other files

Initially, my React App functioned perfectly with global CSS included. However, after running npm i next-images, adding an image, modifying the next.config.js file, and executing npm run dev, I encountered the following notification: "Global CSS cannot ...

I am encountering challenges and confusion with CSS

I am encountering an issue with my code that is causing some difficulties. The goal is to create a basic div with left, right, and center panes. The left pane loads perfectly, but the right pane, which has the same css styling, displays its children with a ...

Generate a visually dynamic representation of a live website page

I'm curious if it's possible to create a login page similar to the one shown in this image, using HTML, CSS, and Javascript. Instead of a traditional background image, I want the background to display the actual layout of another website, such a ...

Adjust the position of the icon in the Mui DatePicker widget

How can I customize the mui DatePicker? I successfully changed the icon, but now I need to adjust its position as well. Instead of being at the end of the text, I want the icon to be at the beginning. Here is my code: <ThemeProvider theme={calendarThem ...

Mathjax2 in React is not supported in React v17

After successfully running recat-matcjax2 on react 16, I encountered some issues when updating to react version 17. I am facing two specific errors: These are the error files: Here is my attempt at implementation: import MathJax from 'react-mathjax ...

Show a dropdown menu based on the selection made in another dropdown menu

<select name = "team1"> <option>Computer Science</option> <option>Mathematics</option> <option>Bioinformatic</option> <option>Management Sciences</option> </select> <select name = "team ...

Issues with JQuery onclick function on dropdown menu functionality not behaving as desired

Take a look at some example code here. Here's the HTML: <div> HTML<br> <li> <select id="Status" type="text"> <option value="New">New</option> <option value="Complete">Complete</option& ...

Ajax loaded scripts are unable to access global variables

Index.html <script> let bar = 1; </script> This html page is being loaded multiple times on the page using AJAX: article.html <script> if (bar === 1) { // perform a task } // Error: bar is not defined </script> Bar is a simple ...

JQuery Menu with Broken UL Formatting on Windows versions of IE and Firefox

Hey there! I've been struggling with a menu design that works perfectly on Mac browsers but is completely broken on Windows. I've spent hours trying to fix it and would really appreciate if a kind programmer could take a look and help me out. The ...

Steps for reverting a widget's background color to its default state following the utilization of gtk_css_provider_load_from_data()

Previously, I would adjust the background colors of widgets using gtk_widget_override_background_color. However, this function is no longer supported, so I am looking to migrate to utilizing GtkCssProvider. I have discovered that I can modify the backgrou ...

What is the best way to align a jQuery Cycle 2 Slider in the middle of the

Having some trouble centering a jQuery Cycle 2 Slider on my page. You can see the slider here. I've attempted multiple methods to center it, but none have been successful. Check out the HTML code: <div class="slider"> <div id=outside> ...

Implementing function invocation upon scroll bar click

I have a Div element with a scroll bar. When a user clicks the scroll bar, I want to call a function based on that click event. How can I achieve this? On the client side, I am using jQuery and on the server side, I am using PHP. I am familiar with makin ...

Achieving priority for style.php over style.css

Having trouble with theme options overriding default CSS settings in style.css. Here's what I have in my header.php: <link rel='stylesheet' type='text/css' media='all' href="<?php bloginfo( 'stylesheet_url&apo ...

Swapping out a code snippet within an HTML document using JavaScript

As a new member of this community, I present to you my very first problem that needs solving. It might be a piece of cake for some of you, but for me, it's proving to be quite tricky. The task at hand involves replacing or removing a string to make ev ...

Is it possible to have square corners on the Vuetify Mobile Drawer component?

Currently, I am working with the Vuetify mobile drawer component and my goal is to give it square corners instead of the default rounded corners that are prevalent in Material design for all Vuetify components. While the Vuetify card component offers a " ...

How can I transmit both the $_POST and $_FILE variables to a .php file using Ajax?

I am looking to integrate an ajax image uploading system into my website for various reasons. I want the upload process to be seamless without having to refresh the page. While some jquery plugins have worked well for this purpose, I encountered an issue ...