When I include a text box in my navigation bar as a list, it occupies the neighboring tab

After inputting the image following the code, you should have a better comprehension.

I devised a navigation bar through an unordered list (ul), yet when I incorporate a text box within my listing, it occupies the neighboring space.

Below is the HTML and CSS code snippet.

<html>
    <head>
        <style type="text/css">
            *{
                margin:0px;
                padding:0px;
            }

            .top-header{
                width:100%;
                height:40px;
                background:#FFFFFF;
            }

            .top-header>img{
                float:left;
                width:70px;
                height:25px;
                padding-left:10px;
                padding-top:8px;
                padding-right:10px;
                padding-left: 100px;
            }

            .signinimg{
                float:left;
                border-left:1px solid #E4E4E4;
                padding-top: 8px;
                height:32px;
                padding-left: 20px;
            }

            .signin{
                float:left;
                padding-top:12px;
                font-family:Arial,Helvetica,freesans,sans-serif;
                font-size:80%;
                padding-right:10px;
                font-weight:bold;
                padding-right:100px;
            }

            .topnav{
                float:left;
                list-style:none;
            }

            .topnav>.t1{
                height:40px;
                width:60px;
                border-left:1px solid #E4E4E4;
                display:inline-block;
                 text-align: center;
            }

            .topnav>.t2{
                height:40px;
                width:140px;
                border-left:1px solid #E4E4E4;
                display:inline-block;
                text-align: center;
                border-right:1px solid #E4E4E4;

            }

            .topnav>.t1>a{
                text-decoration: none;
                color:black;
                font-family:Arial,Helvetica,freesans,sans-serif;
                font-weight: bold;
                font-size:80%;
                line-height:40px;

            }

            .topnav>.t2>a{
                text-decoration: none;
                color:black;
                font-family:Arial,Helvetica,freesans,sans-serif;
                font-weight: bold;
                font-size:80%;
                line-height:40px;
                position: relative;
                left:-40px;
            }
        </style>
        <title>Home-BBC News</title>
    </head>
    <body>
        <div class="top-header">
            <img src="logo.png">
            <div class=signinimg><img src="signin.PNG"></div>
            <div class="signin">Sign In</div>
            <ul class="topnav">
                <li class="t1"><a href="#">News</a></li> 
                <li class="t1"><a href="#">Sport</a></li> 
                <li class="t1"><a href="#">Weather</a></li> 
                <li class="t1"><a href="#">Shop</a></li> 
                <li class="t1"><a href="#">Earth</a></li> 
                <li class="t1"><a href="#">Travel</a></li> 
                <li class="t2"><a href="#">More</a></li> 
                <li class="t2"><a href="#"><input type="text"></a></li> 
            </ul> 
        </div> 
    </body>
</html>

Answer №1

Due to the presence of t2 class with a relative position and left:-40px, I quickly resolved the issue by modifying the li class of the input field. Specifically, I adjusted the width of .t2 to 60px and removed the position and left styles from .t2>a. If you have any inquiries, feel free to ask in the comment section.

* {
   margin: 0px;
  padding: 0px;
}

.top-header {
  width: 100%;
  height: 40px;
  background: #FFFFFF;
}

.top-header>img {
  float: left;
  width: 70px;
  height: 25px;
  padding-left: 10px;
  padding-top: 8px;
  padding-right: 10px;
  padding-left: 100px;
}

.signinimg {
  float: left;
  border-left: 1px solid #E4E4E4;
  padding-top: 8px;
  height: 32px;
  padding-left: 20px;
}

.signin {
  float: left;
  padding-top: 12px;
  font-family: Arial, Helvetica, freesans, sans-serif;
  font-size: 80%;
  padding-right: 10px;
  font-weight: bold;
  padding-right: 100px;
}

.topnav {
  float: left;
  list-style: none;
}

.topnav>.t1 {
  height: 40px;
  width: 60px;
  border-left: 1px solid #E4E4E4;
  display: inline-block;
  text-align: center;
}

.topnav>.t2 {
  height: 40px;
  width: 60px;
  border-left: 1px solid #E4E4E4;
  display: inline-block;
  text-align: center;
  border-right: 1px solid #E4E4E4;
}

.topnav>.t1>a {
  text-decoration: none;
  color: black;
  font-family: Arial, Helvetica, freesans, sans-serif;
  font-weight: bold;
  font-size: 80%;
  line-height: 40px;
}

.topnav>.t2>a {
  text-decoration: none;
  color: black;
  font-family: Arial, Helvetica, freesans, sans-serif;
  font-weight: bold;
  font-size: 80%;
  line-height: 40px;

}

.topnav>.search {
  height: 40px;
  display: inline-block;
}
   

 <body>
    <div class="top-header">
     <img src="logo.png">
     <div class=signinimg><img src="signin.PNG"> </div>
     <div class="signin"> Sign In</div>
     <ul class="topnav">
      <li class="t1"><a href="#">News</a></li>
      <li class="t1"><a href="#">Sport</a></li>
      <li class="t1"><a href="#">Weather</a></li>
      <li class="t1"><a href="#">Shop</a></li>
      <li class="t1"><a href="#">Earth</a></li>
      <li class="t1"><a href="#">Travel</a></li>
      <li class="t2"><a href="#">More</a></li>
      <li class="search">
        <a href="#">
          <input type="text">
        </a>
      </li>


    </ul>

  </div>
</body>

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

What advantages does the use of $(e).attr(name,value) offer compared to using e.setAttribute(name,value)?

Scenario: The variable "e" represents an element of type "HtmlElement" and not a "css selector" I am referring to any attribute, not just the standard allowed ones like "atom-type" or "data-atom-type". Regardless of the attribute name, will it function wi ...

Is there a way to customize the design of the "Browse" button within the HTML file upload control?

I've been searching high and low on the internet for a simple, sleek method to customize the appearance of the Browse button on an HTML <input type=file> element. However, all the solutions I've come across involve hiding controls, placing ...

Stop menu items from shifting when focused

I've developed a mobile hamburger menu and attempted to adjust the padding to create space between the text and the borders. Here's the HTML: #menu-solutions:hover .menu-item-text, #menu-solutions:focus .menu-item-text, #menu-solutions:ac ...

Master Checkbox in HTML Table Not Functioning for Selecting/Deselecting All Items

https://i.sstatic.net/RKWaC.png I'm facing an issue with my code that allows me to select and deselect multiple rows in a table. Specifically, I'm struggling with implementing a SELECTALL/DESELECTALL feature using a master checkbox. You can vie ...

Moving a Div to the Center of the Screen Using Jquery and Masonry JS

I am currently utilizing Jquery Transit and Masonry JS within my project. Within a specific div, there is a button which, when clicked, is intended to change the container's position to fixed and center it on the screen using Jquery Transit. However, ...

Ways to determine if content is visible within a div

My website contains a script that brings in content from an ad network and displays it within a div element. Unfortunately, this particular ad network only fills ads 80% of the time, leaving the remaining 20% of the time without any ads to display. This la ...

Can ngAnimate facilitate conditional transitions?

In my application, I have set up an animation using ngAnimate on ngView where the next view slides in from the right every time there is a state change. Now, I want to be able to reverse this behavior so that sometimes the view slides in from the left (fo ...

Adjusting distinct column widths based on categoryID

Is there a way to assign different CategoryIDs (1, 2, and 3) based on certain conditions and work with varying column widths within <div class="Meta1">? I need to add 2 more CategoryIDs. Any suggestions on how to achieve this? Thank you. if ($ ...

What is the process for enabling CSS modules in React after performing the eject action?

I'm currently working on a React project and I'm looking to enable CSS modules. I recently ran the eject command but I am unsure of where to locate the file in order to set modules to "true" as I can't seem to find the "webpack.config.dev.js ...

Break the line after every space in words within an element

I have a table/grid view with two words in the <td> like "C2 Sunday". I need a line break after C2 so that it appears as: C2 Sunday Is there a way to achieve this? Please assist me with this issue. Currently, it is showing as "C2 Sunday" and I wou ...

Struggling to make Radio Buttons function properly within an ng-repeat loop while using font-awesome icons as labels

I am facing some difficulties with implementing Font Awesome icons for radio buttons in an AngularJS ng-repeat. I have tried different solutions that involve using $parent within the ng-repeat, but none of them have worked for me so far. It is important fo ...

A guide on dynamically altering text upon hovering over an element using Vue.js

On my website, I have the following HTML code: <div class="greetings"> <img @mouseover="hover='A'" @mouseleave="hover=''" src="a.png" alt="A" /> <img @mouseover="hover='B'" @mouseleave="hover=''" ...

Step-by-step guide on incorporating edit, update, and discard functionalities within an Angular Material table component (mat-table)

I am currently working on implementing edit, update, and discard functions in an angular material table. While I have been able to successfully edit and update the table row wise, I am struggling with how to discard table rows. If you would like to see wh ...

How to center a responsive image in a container using Bootstrap

How can I properly center my banner and place the logo above it? Currently, both elements are not centered as desired. View the live version here: http://codepen.io/anon/pen/waYBxB HTML Code: </head> <body> <!-- LOG ...

Nesting divs that soar within a contained div (not spanning the entire page)

I need the div elements to move within another div container instead of flying over the entire page. What changes do I need to make in the code to achieve this? $(document).ready(function() { $('.balloon').each(animateDiv); }); function ma ...

Flexible DIVs with a maximum width of 50% that adjust to different

I'm having trouble getting these two DIVs to display properly within a parent DIV while maintaining responsiveness. I want them to each take up 50% of the screen with a 10px margin between them. Does my current code approach seem correct? .box-cont ...

Optimizing Divs for Maximum Layout Efficiency

My current issue involves a series of divs that contain varying amounts of content. These divs are floated left and I am striving to align them seamlessly without any vertical space between them (except for the 10px margin that I have included). You can v ...

Bootstrap 4: Adjusting text placement on images for various screen sizes

I am trying to achieve a specific text placement on my image, as shown here: https://i.sstatic.net/xgoKo.jpg I want the text slightly off-center from the "Center" point of the image (to avoid overlapping with the phone in the image), so using text-center w ...

Working towards ensuring my website is responsive

Hello, I am a CSS beginner currently working as an intern. My task is to make a website's CSS compatible with Internet Explorer, and then make it responsive and scalable. Essentially, the design should retain its appearance when the window size change ...

What is the best way to create a search bar that overlaps with a filter button?

Desired Ui Looking to create a search bar with a button positioned to the right of it, partially overlapping a banner. Above these elements is a title; however, one issue I'm encountering is that the title covers the search bar when the page size is r ...