Looking to adjust the size of my logo and include a title next to it, all without impacting the size of the navigation bar

I need to resize my logo and add a title beside it without affecting the size of the navbar. Here is how the current navbar looks

HTML:

<header id="header">
<img src="logohtml.png" alt="logo" id="header-img">
  <nav id="nav-bar">
    <ul> 
           <li><a class="nav-link" href="#"><b>Things to Do</b></a></li>
           <li><a class="nav-link" href="#"><b>Where to Eat</b></a></li>
           <li><a class="nav-link" href="#"><b>Events</b></a></li>
           <li><a class="nav-link" href="#"><b>Hotels</b></a></li> 
       <li><a class="nav-link" href="#"><b>Parking</b></a></li> 
    </ul>  
  </nav>

CSS:

header {
    position: fixed;
    background-color: #FFAA63;
    color: white;
    font-family: 'Exo 2', sans-serif;
    padding: 1em;
    width: 100%
}

header::after {
    clear: both;
    content: '';
    display: table;
}

#header-img {
    width: 90px;
    height: 50px;
    float: left;
    padding-top: 1.7em;
}

EDIT:

After applying the suggested code, the logo remains the same size. I want it larger without changing the navbar height.

View updated navbar image here

EDIT: I followed the advice given and successfully resized my logo to fit in the navbar. Thank you! I adjusted the width and played around with the height and width values.

#header-img {
  position: absolute;
  height: 160px;
  width: 250px;
}

See the current navbar design

Answer №1

After reviewing your code, I have made some adjustments to your navbar to enhance its layout and functionality. The following snippet showcases the changes I implemented:

In my solution, I utilized flexbox on the header element to arrange the elements in a row. By using align-items: center for vertical alignment and justify-content: space-between to create space between the logo and the navigation bar.

Update: Feel free to experiment with the modified design on this link: https://codepen.io/DohaHelmy/pen/xxbzzRN

I have repositioned the logo and included a name next to it. Additionally, consider removing the margin-top from the header as it was only added for demonstration purposes.

To view the result more effectively, run the snippet in full-page mode.

header {
  margin-top: 50px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  position: fixed;
  background-color: #ffaa63;
  color: white;
  font-family: "Exo 2", sans-serif;
  padding: 1em;
  width: 100%;
}

#logo{
   display: flex;
   align-items: center;
   font-size: 35px;
   position: relative;
}

#logo span{
   position: relative;
   left: 220px;
}

#header-img {
  position: absolute;
  height: 120px;
}

#nav-bar ul {
  position: relative;
  right: 50px;
  list-style-type: none;
  overflow: auto;
}

#nav-bar ul li {
  float: left;
  margin: 0px 20px;
  color: #fff;
}

#nav-bar .nav-link {
  color: #000;
  text-decoration: none;
}
<header id="header">
   <div id="logo">
      <img src="https://www.freepnglogos.com/uploads/eagles-png-logo/eagle-sports-png-logos--0.png" alt="logo" id="header-img">
   <span>Logo name</span>
   </div>
  
  <nav id="nav-bar">
    <ul>
      <li><a class="nav-link" href="#"><b>Things to Do</b></a></li>
      <li><a class="nav-link" href="#"><b>Where to Eat</b></a></li>
      <li><a class="nav-link" href="#"><b>Events</b></a></li>
      <li><a class="nav-link" href="#"><b>Hotels</b></a></li>
      <li><a class="nav-link" href="#"><b>Parking</b></a></li>
    </ul>
  </nav>
</header>

Answer №2

It seems like there is some confusion regarding your query, but from what I gather, you are looking to shift the position of the logo slightly towards the right without altering the size of the navbar. Alternatively, you may be considering resizing the logo while keeping the navbar unchanged. The solution provided addresses both scenarios.

#nav-bar {
right: 20px;
position: relative;
margin-top: 30px; }

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

The text element does not line up with the icons

As I'm working on creating my first account page header, I've run into an issue with some of the icons not aligning perfectly with the text. While advanced developers may find this task simple, as a beginner, I could really use some advice on how ...

The use of CSS position: fixed can have a significant impact on

Having trouble with responsiveness in my nav-tabs when I apply position:fixed. https://i.sstatic.net/BSiBe.png The image above shows the actual view of my setup. I have two iframes - on the left side is the nav-tab (text-bucket, image-bucket...), in the ...

Require assistance in positioning a div menu within another div

Struggling to create a social media menu for my about page, I can't seem to get it aligned properly within another div or on its own. It appears slightly off center and I'd like it to either float left with a 100px margin or be nested in the othe ...

After applying styling, the modal close button refuses to be clicked

I'm currently facing an issue where I am trying to enhance a modal window with a close button, but encounter problems once styling is applied. The unique aspect of this problem arises from the fact that the close button is not directly in the page HTM ...

Pause Vimeo Video while another video is playing

I have a specific requirement for a webpage where two videos are present. The scenario is that when one video is being played and I decide to start playing the second video, the first video should automatically stop. Essentially, only one video can be play ...

Retrieving the value of an HTML checkbox using onclick or onchange events

<input type="checkbox" onclick="handleClick()" onchange="handleChange()" /> Is there a way to ascertain the new state of the checkbox within the functions handleClick and handleChange? ...

How can you use jQuery to target a textbox based on its value that includes quotation marks?

Dealing with a JavaScript string that includes a quote mark can cause some difficulties. For example, strings like Don't click this checkbox or He said "hi" pose unique challenges when trying to find an exact match in a checkbox value. Consider the H ...

Why are the UI components (`Card Number`, `MM/YY`, `CVC`) not being displayed in the React app when using Card

Having an issue where the CardElement Ui component is not visible in the image provided. It should appear above the Order Total: $0 next to the payment method. https://i.sstatic.net/NCK5z.png I've attempted various debugging methods without success. ...

Steps to get the vehicle approaching the creature

Recently, I ventured into the realm of game development and created a car game where the vehicle moves automatically. However, when the car collides with a monster, I want it to start moving towards the monster instead. After some research, I decided to in ...

Persistent hover state remains on buttons following a click event

In my current project, I am dealing with a form that has two distinct states: editing and visible. When the user clicks on an icon to edit the form, two buttons appear at the bottom - one for saving changes and one for canceling. Upon clicking either of th ...

Ways to constrain checkboxGroupInput items within a designated boundary

My interactive checkboxGroupInput is designed to display the column names from a user-provided input file. Sometimes, this input file contains over one hundred columns. To address this, I followed this answer to organize the choices into multiple columns. ...

I am looking for guidance on removing the bottom line from the ionic 4 segment indicator. Any advice or tips on

.segment-button-indicator { -ms-flex-item-align: end; align-self: flex-end; width: 100%; height: 2px; background-color: var(--indicator-color); opacity: 1; } I am a beginner in hybrid app development and ...

Is autocomplete="off" disregarded by IE 11?

Currently, I am working on an established ASP.NET/C# application that has been in existence for about three years. Recently, for various reasons, I decided to start using the beta version of Internet Explorer 11. However, upon launching the application in ...

Incorporating an image into a list of checkboxes post-connection

Looking for a way to populate a checkbox list through datasource/databind and then integrate an image with each checkbox? I can do both separately but struggling to combine them successfully. My task is to create a checkbox list of students for teachers t ...

Receive the outcome once the form is submitted

Can someone provide quick assistance? I am looking to allow users to upload a CSV file for me to parse and analyze. Once the processing is done, I need to display the results back to the users. While uploading the file, I also need to ensure that the file ...

What is the recommended way to adjust the width of a paper-textarea element in Polymer 1.0?

Is there a way to adjust the width of a paper-textarea? I have tried using CSS selectors within Polymer 1.0 style tags, but it does not seem to be effective. The paper-textarea element is made up of paper-input-container. I attempted the following approach ...

Retrieving the value of onCheck from the Checkbox/ListItem

Imagine I have a React.Component that displays components from material-ui: {data.map(value => ( <ListItem key={data.indexOf(value)} primaryText={value} leftCheckbox={ <Checkbox onCheck={this.pr ...

Utilize Javascript to extract and showcase JSON data fetched from a RESTful API

I'm attempting to use JavaScript to pull JSON data from a REST API and display it on a webpage. The REST call is functioning correctly in the Firefox console. function gethosts() { var xhttp = new XMLHttpRequest(); xhttp.open("GET", "https://10 ...

Setting the height of a webpage element to match the height of the window through CSS

How can I make the .Bck div stretch to the full height of the browser window? I attempted using jQuery, but the height doesn't adjust correctly when I resize the window. What is wrong with my JavaScript and can this be achieved with CSS alone? <!- ...

Is there a way to divide text in half while preserving the HTML structure?

I am in need of setting up an RSS feed where only a portion (or a specified number of characters) of the article's text is displayed, while keeping all HTML tags intact (such as images or YouTube videos). For instance, what should happen if the chara ...