What is the best way to position an element on the left side of the navbar without having it animated?

Could someone assist me in placing the Life's Good logo on the left side of the nav bar without applying the animation from the "btn" class? Below is a snippet of my code with an example where I want the logo highlighted in Yellow:

* {
padding:0;
margin: 0;
}

body {
  font-family: "Roboto";
  color: #fff;
  letter-spacing:1px;
}

a {
  text-decoration: none;
}

.nav-bar {
  padding-top: 18px;
  background: #ffffff;
  padding-bottom: 50px;
  position: relative;
  text-align: center;
  color: black;
}

#main {
  position: relative;
  margin-top: px;
  text-align: left;
}

.btn{
  display: inline-block;
  padding: 15px 40px;
  cursor: pointer;
  letter-spacing: 2px;
  position:relative;
  overflow:hidden;
  margin: 0 1px;
  outline: none;
}

.btn:before {
  content: "";
  position: absolute;
  width: 0;
  background : rgb(0, 0, 0);
  left: 45%;
  height: 2px;
  bottom: 0;
  transition: all .3s;
  opacity: 0.7;
}

.btn:hover:before {
  width: 100%;
  left:0;
}
<!DOCTYPE html>
<html>
    <head>
        <meta charset="utf-8">
        <meta http-equiv="X-UA-Compatible" content="IE=edge">
        <title>Life's Good</title>
        <meta name="description" content="">
        <meta name="viewport" content="width=device-width, initial-scale=1">
        <link rel="stylesheet" href="css/stylesheet.css">
        <link href='https://fonts.googleapis.com/css?family=Roboto' rel='stylesheet' type='text/css'>
        <link rel="icon" href="images/favicon.png">
    </head>
    <body>
        <div class="nav-bar">
                <div id="main"><img src="images/logos/8870080_sunny_sun_beach_cloud_icon (3).png" alt="">Life's Good</div>
                <div class="btn"><a href="index.html" title="">Home</a></div>
                <div class="btn"><a href="#" title="">News</a></div>
                <div class="btn"><a href="#" title="">Gaming</a></div>
                <div class="btn"><a href="#" title="">Books</a></div>
                <div class="btn"><a href="#" title="">Coding</a></div>
                <div class="btn"><a href="#" title="">Contact</a></div>
        </div>
    </body>
</html>

Click here to see the Yellow Area where I want the Logo ("Life's Good")

Answer №1

The issue here is that you forgot to add a number next to px in the margin-top property of #main. It might also be helpful to include a value for margin-left.

If you're looking to exclude the animation from a specific element, you can use the :not() CSS selector to deselect #main.

.btn:before:not(#main)

Answer №2

Ensure that you set position: absolute for the #main element. By doing so, #main will be positioned absolutely in relation to its parent container, which in this case is .nav-bar, as the position of .nav-bar is set to relative.

Afterwards, adjust the margin property of #main based on your requirements. For example, you can use a margin value like margin: 15px 0 15px 75px (top right bottom left).

* {
padding:0;
margin: 0;
}

body {
  font-family: "Roboto";
  color: #fff;
  letter-spacing:1px;
}

a {
  text-decoration: none;
}

.nav-bar {
  padding-top: 18px;
  background: #ffffff;
  padding-bottom: 50px;
  position: relative;
  text-align: center;
  color: black;
}

#main {
  position: absolute;
  margin: 15px 0 15px 75px;
  text-align: left;
}
<!DOCTYPE html>
<html>
    <head>
        <meta charset="utf-8">
        <meta http-equiv="X-UA-Compatible" content="IE=edge">
        <title>Life's Good</title>
        <meta name="description" content="">
        <meta name="viewport" content="width=device-width, initial-scale=1">
        <link rel="stylesheet" href="css/stylesheet.css">
        <link href='https://fonts.googleapis.com/css?family=Roboto' rel='stylesheet' type='text/css'>
        <link rel="icon" href="images/favicon.png">
    </head>
    <body>
        <div class="nav-bar">
                <div id="main"><img src="images/logos/8870080_sunny_sun_beach_cloud_icon (3).png" alt="">Life's Good</div>
                <div class="btn"><a href="index.html" title="">Home</a></div>
                <div class="btn"><a href="#" title="">News</a></div>
                <div class="btn"><a href="#" title="">Gaming</a></div>
                <div class="btn"><a href="#" title="">Books</a></div>
                <div class="btn"><a href="#" title="">Coding</a></div>
                <div class="btn"><a href="#" title="">Contact</a></div>
        </div>
    </body>
</html>

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

Is it recommended to reset heading tag numbering while nesting them?

Consider an HTML book as an example (steering away from the typical blog post). Take a look at this code: <!DOCTYPE html> <html> <head> <title>The title</title> </head> <body> <h1>The title</h1&g ...

CSS resetting can lead to tables appearing misaligned

After applying a CSS reset to my website's stylesheet (which is valid as CSS 2.0 and used with XHTML 1.0 transitional webpage), I noticed that a table on my website no longer looks correct. Specifically, the table is now positioned incorrectly and the ...

CSS overflow property does not take effect when set to hidden

I'm having trouble understanding why the overflow: hidden property is being overridden by a descendant element. Take a look at this example I've put together http://jsfiddle.net/2fRxc/. HTML <div class="relative"> <div class="overf ...

I'm having trouble obtaining accurate results for $....<...$ within the <li> tags using MathJax

I have gained extensive experience working with LaTeX formatting, but not every document follows the standard practice of having a space before and after the symbols < and >. When I attempt to use MathJax to display these documents, they fail to rend ...

How can you prevent a tag from firing in Google Tag Manager by identifying a particular script included in the HTML code

Seeking advice on modifying our Google Tag Manager container as I am a novice when it comes to GTM. Encountering an issue with IE8 on pages utilizing Fusion Charts resulting in a javascript error in gtm.js. Upon investigation, it appears to be related to a ...

Is there a way to apply border-radius to the header of a table in Bootstrap 5?

My use of Bootstrap 5 for styling a table has encountered an issue. Even with the border-radius set on the table-dark class, the thead element's border does not change. I am looking for a way to address this problem. Any suggestions? .table-dark { ...

Strange border adjustment for customized-height input[type=button] in Internet Explorer 6 and Firefox 3

Upon my discovery, I encountered a peculiar issue in IE6/FF3 when trying to set a custom height (even if it matches the default) on a button. The following code illustrates that although both buttons have the same height, their padding differs inexplicably ...

Adjusting the size of content with CSS

I've been attempting to get an image to cover the entire screen on a device using CSS, but so far I haven't had any success. The image is within an :after pseudo element and content tag. Since it needs to be laid over the HTML, I can't use t ...

Converting a key-value pair string into an array in PHP: A comprehensive guide

When the checkbox is selected, I will extract the values listed below: attribute_value:samsung, attribute_id:1, spec_group_id:2, prod_id:1 To convert the above string into an array format and obtain a single array outside of the loop. Therefore, if I wa ...

Having trouble centering elements correctly with Bootstrap 5

Just dipping my toes into the world of bootstrap and experimenting with some code. Encountered an issue when trying to center elements properly within columns: <div class="container"> <div class="row"> <div class= ...

Personalized color scheme for calendar td

I am facing an issue with my event calendar where I want to change the background color of td. I came across a helpful solution in this question, but it did not fully solve my problem. When I implemented the following jquery: $('[class*="fc"]'). ...

Adjust the background color of children based on the parent's mouseover event

Seeking a solution to fill three bars with varying percentages: <div class="bars" style="width:0%; background-color: red;"> <span class="bar"></span> <span class="bar"></span> <span class="bar"></span> </ ...

Require the capability to bypass inline CSS styling

Currently facing an issue with a wordpress website I am constructing using iThemes Builder. The problem arises when integrating the plugin Jquery Megamenu, as the drop-down menu gets truncated due to an overflow:hidden property that cannot be overridden i ...

The Angular JS routes are not properly loading the required file from the provided TemplateURL when receiving a response from Node

I am trying to retrieve data from a MySQL database using node (routes.js) and have the results injected into club.html, which is then dynamically updated in index.html using ng-view. However, it seems that the JSON response from node is displaying directly ...

The GIF Loader fails to animate while an AJAX request is in progress

Displaying a DIV element containing a loading GIF image while waiting for an AJAX call response. Initially, the DIV element is hidden. Upon clicking a checkbox, the loader DIV is shown, followed by the completion of the AJAX call, and then hiding the load ...

Retrieving CSS style values with Node.js

I am looking to design a new CSS style that includes the lowest and highest values. table[my-type="myStyle"] { width: 255.388px !important; } This code snippet is included in numerous CSS files within my style directory. ...

Unlock the potential of HTML5 Datalist: A comprehensive guide on integrating it with

The latest version of HTML, HTML5, has introduced a new tag called datalist. This tag, when connected to <input list="datalistID">, allows for autocomplete functionality on web forms. Now the question arises - what is the most efficient approach to ...

How can I ensure that my image remains responsive and aspect ratio-friendly?

Is there a way to accomplish this magical effect? I find myself in a similar situation. I require an image that remains centered while adjusting to fit the screen, all while maintaining its aspect ratio. ...

Radio buttons failing to transfer any data

I am experiencing an issue with setting values for radio buttons and using the $_POST variable to read the value, but the value being set is empty. <form style="text-align:left;margin-left:80px;" class="form-inline signup" role="form" method="post" act ...

Issue with Bootstrap: Nested column disappears upon reaching the breaking point

I want to create a grid with 3 columns, each containing a nested grid with 2 columns (one smaller than the other). When the breakpoint is reached, I want the columns to stack on top of each other. However, one of the nested columns disappears after the br ...