Is it possible to relocate my navigation bar?

I am struggling to align my top horizontal navbar to the right next to the header that reads "Best TV Ever". I have already floated it to the right, but now I need it to move up to the top of the page.

Can anyone help me with this?

Here is the link to the jsfiddle: https://jsfiddle.net/qkLgqmfh/

Below is the code snippet:

h1{
    background-color: black;
    background-image: url(logo.png);
    background-repeat: no-repeat;
    font-family: Peralta;
    color: white;
    height: 100px;
    padding-top: 25px;
    padding-left: 150px;}

h2{
    font-family: Peralta;
    text-align: center;
    height: 25px;
    background-color: white;
    padding-top: 0;
    height: 50px;
}

p{
    border-bottom: 1px solid black;
    padding-bottom: 3em;
    display: block;
    overflow: hidden;
    height:130px;
}

img{
    float: left;

    margin-right: 1em;
    width: 150px;
    height: 100px;
    padding-left: 10px;
    border-radius: 20px;}



ul li {
    display: inline-block;
    float: right;
    padding-top: 0;
}

.topnav ul li a:link{
    text-decoration: none;
    color: black;
    background-color: white;
    border-radius: 50%;
    margin: 15px;
}
  
<body>
    <div class="wrapper">


<div id="masthead">
    <h1>Best TV Ever</h1>
        </div>


[insert menu toggle here]
[insert menu checkbox here]

<div class="topnav"> 
<ul>
    <li><a href="#">50s</a></li>
    <li><a href="#">60s</a></li>
    <li><a href="#">70s</a></li>
    <li><a href="#">80s</a></li>
    <li><a href="#">90s</a></li>
    </ul>
        </div>

I've been staring at my computer screen for hours and cannot seem to figure out this simple task. My mind feels exhausted, and I'm hitting a roadblock. Can someone please provide guidance on this issue?

Answer №1

It appears that the issue lies in placing the float: right; on the li instead of the .topnav.

After making this adjustment and decluttering the code, here is the updated result: https://example.com/code123

This should align with your desired outcome.

Update: To achieve a black background across the full width, combine the topnav and h1 within a new div and apply background-color: black;. Since the div only contains floated elements, remember to include overflow: hidden; to ensure proper rendering (unless specifying a specific height).

If adjusting link sizes, simply modify the font-size.

Take a look at the changes here: https://example.com/code456

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

Looking for subsequence in dropdown choices with no assigned values

I need assistance with searching for a specific substring within text that is fetched from options generated by MySQL. How can I retrieve the selected option's text value in order to search for my desired substring? $(document).ready(function() { ...

Trigger animation once you've scrolled past a designated point in the document

I created a count-up counter animation using JavaScript, but the issue is that the counter starts animating as soon as I refresh the page regardless of where I am on the page or if the counter is even visible. I would like the counter to only start workin ...

Creating a function to update data in a Node.js/MongoDB environment

Hey there! I'm new to working with nodejs and mongodb, and I'm trying to create a function that updates the win, lose, and draw record in my UserSchema. Here's my Schema: UserSchema = new mongoose.Schema({ username:'string', ...

Leveraging Angular 2 directives in TypeScript to bind a value from a custom control to an HTML control

I have created a unique custom directive named "my-text-box", and within this directive, I am utilizing the HTML control <input>. I want to pass values from my custom control to the HTML input control. In Angular 1, I would simply do something like & ...

Utilizing jQuery to display labels only for selected checkboxes while concealing the ones that are not checked

I currently have the following setup: <style>.selectit{display:none;}</style> <div id="foo"> <label class="selectit"> <input type="checkbox" name="one" id="one" checked> One </label> <label class="selectit"> <i ...

Utilize xdebug and NetBeans 8.2 to troubleshoot PHP code submitted through an HTML form

After successfully setting up the XDebug extension to debug PHP code within NetBeans IDE (ver. 8.2), I encountered an issue. While debugging works fine when setting a breakpoint and running the script in debug mode, I am having trouble debugging PHP code t ...

Have I incorrectly implemented responsiveness on my website?

I created my HTML using Bootstrap 3.3.7: <html> <head> <meta charset="UTF-8"> <meta name="viewport" content="width=device-width, initial-scale=1.0"> <meta name="copyright" content= ...

Extracting data from the web using PHP

I'm facing an issue with my code that scrapes data from a website. The current output looks like this: Agriculture Food Apparel I want to only display the first/nth category, for example just "Agriculture". I attempted: echo $sub_title[1].&ap ...

Can you help me with sorting asynchronous line points for KineticJS?

For the past couple of days, I've been grappling with a peculiar issue that I found difficult to articulate in the title. The challenge I'm facing involves a KineticJs Line, which contains an array of points (line.attrs.points) represented as ob ...

.value not showing correct data in JavaScript

I am attempting to retrieve the value entered by the user in an HTML input field. While I can display a fixed, predetermined value with ease, this is not my intention. My goal is for users to input a numerical value and for that value to be displayed/adj ...

MUI useStyles/createStyles hook dilemma: Inconsistent styling across components, with styles failing to apply to some elements

I have been trying to style my MUI5 react app using the makeStyles and createStyles hooks. The root className is being styled perfectly, but I am facing an issue with styling the logoIcon. Despite multiple attempts to debug the problem, I have not been suc ...

The ASP.Net email contains a hyperlink designed to open in a new window

I am currently facing an issue with an email I need to send. The problem lies in the hyperlink that is intended to open a specific page in a new tab or window upon clicking. The main issue at hand is that there is no space between the querystring variable ...

Specify the height of a div tag based on a certain condition

I'm trying to style a div tag in a specific way: If the content inside the div is less than 100px, I want the div tag's height to be exactly 100px. However, if the content's height exceeds 100px, I want the div tag's height to adjust au ...

Accessing and showcasing MySQL information using hidden forms

I'm facing an issue with displaying the selected data from MYsql. The values are stored in my database fields, and I want the review of the chosen movie to show up when the user clicks the submit button, but it's not working as expected. Below i ...

What is the method for retrieving the index of an array from an HTML element?

Howdy! Within my Vue application, I have the ability to create multiple individuals: <div v-for="newContent in temp" :key="newContent.id" @click="showId(newContent.id)" v-show="true"> <!-- ...

Having difficulty changing the value of a Select element in AngularJS

Struggling to update the select value from AngularJs. Check out my code below: <select ng-model="family.grade" > <option ng-repeat="option in options" value='{{option.id}}'>{{option.text}}</option> </s ...

Insert round sphere shapes in the corners of the cells on the Table

I am working on a GUI representation table that features cells with spheres in the corner. Additionally, the footer contains a plus symbol (font-awesome icon) in the corner. I have attempted to place the sphere so that it aligns only inside the cell. Here ...

Defending Against SQL Injection Vulnerabilities

Greetings everyone! I'm currently working on developing a website that will feature a forum. As part of this process, I've been researching potential security vulnerabilities that could impact the site, such as cross-site scripting and SQL inject ...

An incessant stream of onclick events is being triggered

My HTML code consists of a jQuery script and a button that triggers a function to display random answers. However, after clicking the button once, the answers cycle automatically without any input. I want each click to show a different answer. What could ...

Selectize Fails to Populate Options Using Ajax

ExpressJS is the platform I am using to develop a management dashboard for a community project. Right now, my main concern is integrating a modal that allows users to add new games to a database. Although I am able to fetch data remotely, I am facing diffi ...