Ways to ensure text wrapping occurs with floated elements

Check out this image showcasing my issue.

Do you notice how the hamburger/menu icon gets bumped down to the next line? My goal is to have the text wrap to the next line instead, while keeping the menu button and header text aligned side by side. The title text and menu are set to float left and right respectively.

This seems like a confusing problem (as I'm trying to achieve the opposite), and I can't figure out how the white space property might help in this scenario.

The only solution that somewhat works is putting a max width on the title, but that ends up messing with the layout at certain screen sizes.

I haven't added any custom css to these elements, just using what Bootstrap 3 provides

Here's the markup (pretty much copied from the new Bootstrap 3 docs):

<div class="navbar navbar-default">
    <div class = "navbar-header">
      <a class = "navbar-brand" href="<%= request.protocol + request.host_with_port%>/weather"> Weather </a>

  <button type="button" class="navbar-toggle" data-toggle="collapse" data-target=".navbar-ex1-collapse">
    <span class="sr-only">Toggle navigation</span>
    <span class="icon-bar"></span>
    <span class="icon-bar"></span>
    <span class="icon-bar"></span>
  </button>

  </div>
<div class="collapse navbar-collapse navbar-ex1-collapse">
  <form id="search" class="navbar-form navbar-right form-inline" method="get" action="/weather">
    <div class="form-group">
      <input type="text" placeholder="Search for your city or zip" class="form-control" id = "searchbox" name="search">
    </div>
    <button type="submit" class="btn btn-default"><span class="glyphicon glyphicon-search"/></button>
  </form>
</div>

`

Answer №1

Hey Stephen,

To achieve the desired outcome, you'll need to make two adjustments.

Firstly, ensure that the padding-right for .navbar-brand is set to 70px or your preferred value.

.navbar-brand {
    padding-right:70px; 
}

Secondly, position .navbar-toggle absolutely with right:0;

.navbar-toggle {
    position:absolute;
    right:0;
    top:0;
}

Once these changes are in place, you will be good to go! :).

Check out the demo here: http://jsfiddle.net/pALiX/

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

Collapse all "Read More" buttons simultaneously using Bootstrap

I am attempting to design a segment that contains multiple paragraphs that can be expanded or collapsed individually. How can I achieve this using only pure bootstrap css so that they do not all expand and collapse simultaneously? #summary { font-size: ...

Utilizing the modulo operation for organizing rows and columns

I’ve seen this question asked many times, but I’m still struggling to figure it out. The examples I’ve come across are either too complex or involve Angular or Javascript. My goal is to learn how to set up 4 columns within a row. // initiating a ...

Ways to make two blocks of text appear side by side and adapt to different screen sizes

Check out our website imageI'm facing a challenge in making these two text elements appear next to each other rather than stacking on top of each other. Additionally, I need them to adapt responsively to changes in screen size. When 'Icontext&ap ...

Persistence of local storage in iOS and Android web views

I am facing an issue with data persistence in HTML5's localstorage when using ios/android webviews for a hybrid app. I utilize local storage to save necessary data on the HTML side of my app but have encountered some unexpected behavior. Despite not c ...

Unique CSS design with an accentuated border

I was experimenting with creating a corner using CSS and managed to achieve something like this: .left-corner { width: 0; height: 0; border-top: 100px solid powderblue; border-left: 100px solid transparent; } <div class="left-corner"></ ...

Stop horizontal overflow of content

This unique Vuetify demo on CodePen showcases a two-column layout. The first column contains a <v-list> enclosed in a green <v-alert>. By clicking the "toggle text" button, you can switch the title of the first list item between short and long ...

Utilize various CSS styles for individual sections within a multi-page website

Having a web page with multiple subpages each having their own specific CSS can be quite challenging. Sometimes, when all the CSS files are applied globally, they tend to mix with each other causing a headache for developers. One common approach is to decl ...

why isn't bootstrap 4 pull-xs-right functioning properly?

I am utilizing Bootstrap 4 utilities to align buttons to the right of the screen in my HTML, and it is achieving the desired effect. However, I am facing an issue where the buttons are not pushing down the content below them as anticipated. Instead, they ...

Using Python's BeautifulSoup library to pull information from an HTML table

I need help extracting a table from a webpage. Here's the HTML and Python code using beautifulsoup that I've been trying with. It usually works for me, but this time it's coming up blank. Any insights are appreciated! <table> <thea ...

Challenges with integrating a Bootstrap 4 table into a card component

Here is a problem I am facing. It seems that the table inside the card is not displaying correctly. I want the table to be centered or at least eliminate the blank space that is currently showing. Here is my code (using Angular 6): <div class="row ...

Having trouble aligning text beside Bootstrap input field

I have a form using the Bootstrap framework where I want text on the left of every input to show its purpose. However, the text ends up above the input field like this: Current appearance of the form: https://i.sstatic.net/GUHcO.png <div class="contai ...

Is it possible to conceal specific sections of a timeline depending on the current slide in view?

For my product tour, I've structured a timeline with 4 main sections, each containing 4-5 subsections. Here's how it looks: <ul class="slideshow-timeline"> <li class="active-target-main main-section"><a href="#target">Targe ...

Using a CSS hack to create a border cutout

The Dilemma... I am attempting to position div elements over a border, while maintaining space on both sides of each div. Take a look at the scenario: Note the gaps surrounding the black divs. I am struggling to find a solution for this issue, aside fro ...

Use HTML5 and CSS3 to align text in the center of the page below the header

I am currently in the process of transitioning from using old HTML tables for styling to utilizing HTML5 with CSS. However, I am encountering some difficulties: Check out my Codepen Demo The issue I am facing is that the text aligns itself to the edge of ...

What is the process for including id parameters within the URL of an HTML page?

As I work on building a website with ReactJS and webpack, I encounter the need to access URL parameters. One specific challenge I face is creating a universal blog post view page that can be dynamically loaded based on the blog id parameter in the URL. Rat ...

Shift div position when clicked and employ jQuery animations

I have been attempting to add animation to a DIV element by using jQuery. The goal is to move the DIV from the center to the left when it is clicked, but I am encountering some issues. The parent div has a position of "relative", and my initial idea was to ...

The default values for CSS filters

I have a keen interest in various CSS filters: blur brightness contrast grayscale hue-rotate invert opacity saturate sepia Could someone provide the default values for each filter (preferably as a % value, where applicable)? The MDN documentation does no ...

What is the best way to add a line break to a menu item?

Looking for some assistance with Angular Material here. I am trying to design a menu that includes an item with two lengthy paragraphs, but the text is getting truncated and only showing the first paragraph. If anyone could offer guidance or help, it woul ...

Table with checkboxes for row selection

Hey there, I've just set up a table with some values. My goal is to select all checkboxes with the first checkbox and uncheck them. print "Content-type: text/html; charset=iso-8859-1\n\n"; my $script = qq{ \$('#id').change(fu ...

The size of table td is less than 100%

I'm having trouble getting my td to fill 100% of my table. I have tried using the following code: .table-scroll tbody { display: block; overflow-y: scroll; height: calc(100% - 130px); } Even with the display block property, the td element is s ...