Center the panel on the page and decrease its width using Bootstrap

I recently incorporated a Bootstrap panel above a search results table - my first experience working with Panels. This panel contains a form with a select menu, allowing users to filter the list of search results based on their selections.

Currently, the panel and select menu are both too wide, spanning the full width of the table. I am looking to reduce the Panel's width by approximately 1/3 and center it on the page, but I'm unsure if this is achievable or how to go about it.

Here is the HTML code for reference:

<link href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap.min.css" rel="stylesheet" />



<div class="container">


  <div class="text-center">
    <ul class="pagination">
      <li class="disabled"><a href="#">First</a></li>
      <li class="disabled"><a href="#">Previous</a></li>
      <li><a href="?action=searchAssets&prNumber=&assetTag=&serialNumber=&assetID=AT&skip=20">Next</a></li>
      <li><a href="?action=searchAssets&prNumber=&assetTag=&serialNumber=&assetID=AT&skip=13220">Last</a></li>
    </ul>
  </div>
  <div class="text-center">
    <span class="counter-items"><span class="counter-num-items">1-20 / 13233</span></span>
  </div>

  <h1>Search Results</h1>

  <br>

  <div class="panel panel-primary">
    <div class="panel-heading">
      <h3 class="panel-title">Filter By</h3>
    </div>
    <div class="panel-body">
      <form class="form-horizontal" id="filter" action="filter.php" method="get" role="form">
        <input type="hidden" name="action" value="filterSearch">
        <div class="form-group">
          <div class="col-sm-9">
            <select class="form-control" name="productType" id="productType">

            <option selected="selected">By Product Type</option>
                                                          <option value="Cars">Cars</option>
                                                            <option value="Trains">Trains</option>
                                                            <option value="Planes">Planes</option>
                              
        </select>
          </div>
        </div>
      </form>
    </div>
  </div>

Answer №1

To properly display your panel, make sure to enclose it within a div element with the following classes: col-xs-offset-3 col-xs-6. See example below:

 <div class=" col-xs-offset-3 col-xs-6">
    <div class="panel panel-primary">
         ----
    </div>
 <div>

Answer №2

It seems like you're looking to center and reduce the width of your panel to one-third.

To achieve this, you can assign an id (panel1) to the panel and apply the following CSS:

<div id ="panel1" class="panel panel-primary">

<style>
  #panel1 {
    width:30%; 
    height:auto;
    margin:0 auto;
    text-align:center;
  }
</style>  

Answer №3

It appears that you are hesitant to utilize the Column Layout feature in your code. However, there is a way to adjust the width of the panel and position it at the center of the page without using it. You can customize the CSS style for the Panel by overriding bootstrap's default settings. Simply insert the following code into the <head> section of your HTML file:

<style>
  #panel-center{
    width: 20%;
    margin: 0 auto;
    }
</style>

Make sure to add the id "panel-center" to this line

<div class="panel panel-primary">

While this solution may resolve your issue, it is not considered an optimized approach. I recommend utilizing the Column Layout(Grid) for better results. Thank you.

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

Issues with Bootstrap Contact Form submission

I found a helpful tutorial for creating a form at the following link: After following the tutorial, I added these scripts to the bottom of my contact form HTML: <script src='https://code.jquery.com/jquery-1.12.0.min.js'></script> ...

Is your Bootstrap input displaying the has-error class with a glyphicon, but the alignment is not vertically centered?

What is the reason for the misalignment of glyphicon-warning-sign form-control-feedback vertically in the code below after applying font-size: 20px; to the label? <div class="container"> <div class="content align-left contact"> ...

The wrap() method in jQuery clones elements multiple times

I have created a simple function that wraps a div tag inside another div tag when the browser window exceeds a certain width of x pixels. However, I've encountered a strange bug when resizing the page more than once. Let me share with you the jQuery ...

How can I make two lines equal in length by stretching them?

Looking to replicate the design shown in the image below using CSS: https://i.stack.imgur.com/cZiFT.png It's crucial for me that both lines are of equal length: https://i.stack.imgur.com/8phWR.png I attempted to recreate it with the following code ...

What is the process for implementing the Google Analytics tag on a Streamlit-built website?

I want to monitor my Streamlit UI in Google Analytics. To achieve this, Google Analytics requires the following code snippet to be inserted into the <head> section of the HTML file. <script async src="https://www.googletagmanager.com/gtag/js? ...

Issues arise with tabbed content as default content fails to display and classes are not added upon clicking

I'm currently working on a tabbed module that consists of three tabs. Here's how it operates: When the user clicks on a carousel_element, it reveals carousel_hidden-text within that div and displays it in another div called carousel_quote. I&ap ...

How can I create a dynamic height for a scrollable div?

How can I build a section with a defined height that contains a sticky header (with a dynamic height) and a scrollable body? I want the body to be scrollable, but due to the header's changing height, I'm unable to set an exact height. What should ...

What are some ways I can customize this jQuery :submit selector demonstration?

After reviewing the jQuery example provided here, I am curious about how to adjust the code in order to change the color of a cell only when the value of the submit button within that cell meets certain criteria. For instance: var submitEl = $( ...

Tips for implementing a search filter in a select dropdown menu using Angular

I am attempting to enhance my select option list by including a search filter. With numerous options available, I believe that having a search function will make it easier for the user to locate their desired selection. I hope my message is clear despite ...

Floating elements overlapping fixed elements

I am currently in the process of developing a mobile application and encountering an issue with relative divs overlapping the top and bottom headers fixed with a z-index. Despite my attempt to resolve this by adding a z-index to the relative div, the probl ...

Drop and drag to complete the missing pieces

Here is a drag and drop fill in the blanks code I created. The challenge I'm facing is that I want users to be able to correct their mistakes by moving words to the right place after receiving points. <!DOCTYPE HTML> <html> <head&g ...

Getting the chosen value from a dropdown menu on form submission using PHP

How to Populate a Combo Box from a Database in PHP? <td>Item Name:</td> <td><select name="items"> <option value="0" selected="selected"> Choose</option> <?php while($row = mysql_fetch_ass ...

Unable to properly connect my CSS file to the header partial

I am struggling to include my CSS file in the header partial Here is the link I am using: <link rel="stylesheet" href="stylesheets/app.css"> This is what my directory structure looks like: project models node_modules public stylesh ...

Is there a way to adjust the orientation of a <video> element without affecting the orientation of the video controls?

<video controls> </video> video { transform: scaleX(-1) } This CSS code flips the video horizontally, but it also flips the control buttons along with it. I attempted to flip the wrapper element containing the video using .wrapper {transfor ...

Guide on generating a child element in a React application using server response

I have developed a react application with multiple nested routes. One of the nested routes utilizes a backend API that returns complete HTML content. My goal is to display this HTML content with the same styling in my UI without directly manipulating the ...

Implement a jQuery loading animation triggered by scrolling down the page

Can anyone offer guidance on how to trigger an animation as you scroll down a webpage? I've come across this feature while browsing through this website: I would love to include code examples, but I'm unsure of where to start with implementing t ...

Using jQuery validation to verify that a minimum of one radio button holds a true value

I have a form with two questions. The first question asks if the product value exceeds a certain fixed amount, and the second question asks if the product value is below that fixed amount. Upon submitting the form, validation should ensure that at least on ...

Challenger arises in the realm of Chakra UI styling

Recently, I've encountered an issue with displaying a card using chakra UI and next js. The CSS of chakra UI seems to be messed up, causing all my components to display incorrectly. It was working perfectly fine until yesterday. I tried deleting the . ...

Has there been a recent issue with FireFox 3 where it fails to clear a float and does not recognize negative margins?

I've been searching online, but haven't come across a definitive answer yet. I'm interested in knowing if there is an issue with Firefox 3 when applying a negative margin to a div that is either clearing a float or containing another floated ...

What are the different ways to customize the indicator color of React Material UI Tabs using hex

Just got my hands on this amazing Material UI component <Tabs textColor="primary" indicatorColor="primary" > <Tab label="All Issues"/> </Tabs> The documentation states that indicatorColor and textColor can only be set to ' ...