Creating an expandable search box that overflows other content: A step-by-step guide

I am facing an issue with a search box that expands when activated. However, I want the search box to break out of the Bootstrap column and overflow other content on the page. How can I achieve this?

Here is the CSS code for the search box styling:

.search-area {
  transition: all .3s ease-in;
  width: 3rem
}

.search-area:focus-within,
.search-area:hover {
  width: 100%;
}

.page-searchform {
  position: relative
}

.header-search {
  padding-right: 2rem;
  border: 0;
  background-color: #fff;
}

.header-search-btn {
  position: absolute;
  top: 50%;
  right: 0;
  transform: translateY(-50%);
  display: flex;
  align-items: center;
  justify-content: center;
}

/* Presentation only */
.row {
  background: #f8f9fa;
  margin-top: 20px;
}

.col {
  padding: 10px;
  border: 1px solid #ccc;
}

Here is the HTML code for the search box within the Bootstrap column:

<div class="container">
  <div class="row">
    <div class="col col-10">
      Column 1 - Make search input overflow me!
    </div>
    
    <div class="col d-flex justify-content-end align-self-center">
      <div class="search-area">
        <form class="page-searchform" action="" method="get">
          <label for="headerSearch" class="visually-hidden"></label>
          <input name="" id="headerSearch" class="header-search form-control" type="search" placeholder="Search...">
          
          <button class="btn header-search-btn" type="submit" id="headerSearchBtn">Go
          </button>
        </form>
      </div>
    </div>
  </div>
</div>

You can view the JsFiddle here for more details.

Answer №1

Have you considered implementing position:absolute along with right:0?

.grow-area:hover .navigation-bar{
   transition: all .3s ease-in;
    width: 500px;
}

.navigation-bar {
  padding-right: 2rem;
  border: 0;
  background-color: blue;
  position:absolute;
  right:0;
  width: 100px;
}

https://jsfiddle.net/23c94ftw/16/

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

Make sure to have the list available while choosing an item

I want to design a unique CSS element with the following characteristics: Include a button. When the button is clicked, a list of items (like a dropdown list) should appear. We should be able to select items by clicking on them, and the parent component s ...

Disable the moving of the DIV button with a left-margin of 0px

Having a bit of a challenge here. I'm attempting to craft my own slider using jQuery along with some css and javascript. I've managed to get my slider functioning, moving a Div 660px to the left and right upon button clicks. However, I'm h ...

What are some ways to display unprocessed image data on a website using JavaScript?

I have an API endpoint that provides image files in raw data format. How can I display this image data on a website using the img tag or CSS background-image property, without utilizing canvas? One possible approach is shown below: $.get({ url: '/ ...

Creating visually appealing websites is made easy with Bootstrap 5's innovative image and

I am working on a Bootstrap 5 website template and I want to add text with a white background in the center of an image. Instead of seeing just a white color over the image, I would like to have a white rectangle with a title and text centered on the imag ...

Arranging Bootstrap buttons in a clean row

How can I add two nav buttons "register" and "sign in" to the top right of my navigation bar, and include a separate button "request a demo" below them without displacing the first two buttons? I am currently using a br tag to push the third button down ...

Tweaking react-lottie and SVG dimensions with CSS media queries: A step-by-step guide

I am currently working on a React project that involves displaying Lottie-react animations and SVG's. My main concern is making sure that these illustrations are responsive on my website. The components are stored in a .js file, which I import into m ...

What is preventing Firefox and IE from displaying images fully in a list item?

I am trying to create a slideshow with two separate sliders using li elements for that purpose. It works perfectly in Chrome and Safari, but I am encountering issues in Firefox and IE. In Firefox, the slideshow works fine in quirks mode but not in standar ...

The vertical writing mode is causing boxes to stack in an unexpected direction

I am encountering an issue with three div elements that have a writing-mode of vertical-rl. Despite setting the writing mode to vertical, the block stacking context is not being displayed from left to right as expected, but rather stacking inline. CSS .v ...

Adjust the width of a class using CSS transitions when hovering

Is there a way to use pure CSS to adjust the widths of classes on hover? Although the transition is successfully changing the classes, class .b and .c are not impacting the width of classes that come before them. Ideally, I would like the previous class ( ...

jQuery UI DatePicker: without any styling, no picking dates

I'm struggling to configure a jQuery UI DatePicker. I moved the development-bundle folder contents to the directory res/jqueryui and initialized two datepickers as shown below: <script src="res/jquery-2.1.0.min.js"></script> <script sr ...

I am currently grappling with a JavaScript mouse over event and encountering some difficulties

I am looking to dynamically change the background image of my body div whenever a link is hovered over. Here is a snippet of my code: JAVASCRIPT: var i = 0, anchors = document.querySelectorAll("zoom"), background = document.getElementById("body") ...

How come the element is not appearing in the div even though it should be there?

The placement of the image and select menu within the same div element may be causing a display issue where only the first image is shown correctly and the select menu appears outside. Why does this occur? <body> <div style="height: 1080px; ...

employing JavaScript to present an image

Here is the image code I have: <img id="imgId" src="img/cart.png" style="display: none"/> After clicking a button, it triggers a JavaScript function to show the image document.getElementById("imgId").style.display = "inline" The image display ...

Tips for successfully implementing overflow-x in a timeline layout without causing any format disruptions

I've been working on a dynamic timeline design that adapts to different screen sizes. I applied overflow-x property to prevent horizontal scrolling in the mobile version, making the burger menu's sub-items visible without requiring a click. Howev ...

I'm having trouble changing the background color of a blank document in Brackets using external CSS

I have been utilizing Brackets for a project at school and attempting to align div tags side by side, but I am not seeing any changes in the visual display of the code. I started to suspect an issue with the external CSS, so I tried altering the background ...

.displaying a grid of div elements is not functioning as expected

On a single page, there is a grid of Divs (2 by 3) with a menu (<li> in <lu>) positioned to the left of the grid. Each menu section contains its own grid of divs, all enclosed within one main div to facilitate manipulation. Menu Sections: < ...

Is the background color extending the entire width of the page?

Hey there, I'm currently trying to determine how to set the background-color on a paragraph or h1 so that it only appears behind the words and not across the entire page with blank space. I'm still a beginner when it comes to coding. I'm wor ...

CSS for two columns with a width of 50% each

Below is a table for reference: <table width="100%"> <tr> <td id="td1"></td> <td id="td2"></td> <td id="td3"></td> <td id="td4"></td> </tr> </table> Is there a wa ...

Add a class by utilizing the :class attribute

I reviewed the documentation, but I am still struggling to implement this in my project. Initially, I simply want to display a specific class using vue.js that I can later modify dynamically. I just need to establish the default behavior of that class, so ...

Achieving a full-width image display in Bootstrap: A guide

I've been struggling to find a solution to stretch an image across a div using CSS and Bootstrap. I attempted to make both the div and parent container fluid, but no matter what I try, there always seems to be some white space on the left and right si ...