The width of the navigation bar adjusts after it becomes fixed to the top of the page

When scrolling past the navigation bar, it sticks to the top but expands beyond the container width. How can this issue be resolved so that the navigation bar retains its original width? Check out my code on GitHub: https://github.com/Archiie/MyPortfolio

The rest of the HTML, head tag, links, body, and content are defined similar to what was previously shown.

Answer №1

Verify its functionality now; when it becomes sticky, its position is fixed so you need to assign a width or set left and right positions for it

.affix {
top: 0px;
margin: 0px 20px;
  width:1100px;
}
@media (max-width: 1199px)
{
.affix {
    width: 900px;
}
}
@media (max-width: 991px)
{
.affix {
    width: 680px;
}
}
@media (max-width: 768px)
{
.affix {
  left:15px;
  right:15px;
  width:auto;
}
}

.affix + .container {
padding: 0px;
}

h1, h4 {
text-shadow: 4px 5px 3px #A866B2; /*#DCD4F9, #F74554 moves to the right, moves down, thickness of text's shadow*/
}
.main-container {
margin: 40px 0px;
border-radius: 10px;
background-color: #4B004C ; /*#800000, #4B004C, #E6E6E6*/
}

#head_tag, #footer_tag {
font-family: Tangerine, Monospace;
color: white;
}
#head_tag {
font-size: 100px;
height: 300px;
}
#footer_tag {
font-size: 50px;
}

.image {
border-style: solid;
border-radius: 50%;
border-width: 1px;
border-color: #000;
height: 230px;
width: 240px;
}
.img-responsive {
margin: 20px auto;
}

.navbar {
margin: 0px 20px;
z-index: 1;
}

.info {
font-family: Monospace;
font-size: 20px;
background-color: #E6E6E6; /*#4B004C, #E6E6E6*/
border-radius: 10px;
margin: 20px 20px;
padding: 20px 20px;
}
.boxSpacing {
margin: 20px auto;
}
.pics {
height: 300px;
width: 300px;
}

#aboutMe, #portfolio, #contactMe {
font-family: Lobster, Monospace;
font-size: 35px;
color: #6E326F;
}

.centeringIcon {
display: block;
text-align:center;
color: white;
}
<!DOCTYPE html>
<html>
<head>
<title>Portfolio</title>


...

</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

Struggling with configuring AngularJS?

I've been working on a simple setup, but I can't figure out why AngularJS isn't displaying the content within the curly brackets. It's got me completely baffled. If you'd like to check it out, here's the link to the plunker: ...

Implement the use of HTML buttons to dynamically change the source attribute of an image using

I am in the process of creating a webpage with 25 different images that will be displayed one at a time. Each image represents unique combinations from two sets of items: (ant, blueberry, ladybug, marshmallow, mushroom) and (blimp, truck, moon, ocean, redw ...

Looking to adjust the fill pattern dynamically

I previously implemented this code: Is there a way to modify the fill image on my 3 buttons to display in 3 distinct colors instead? ...

What is the best way to retrieve the information stored in an object?

let items = { 1001: {item: 'Chocolates', price: 10, quantity: 10}, 1002: {item: 'Biscuits', price: 10, quantity: 10}, 1003: {item: 'Bread', price: 20, quantity: 5}, 1004: {item: 'Milk', price: 25, quantity: 5}, 1005: ...

Utilize Boostrap to stylishly incorporate an image within a DIV using CSS

I have a project with numerous HTML pages all containing the same elements. To make updating easier, I decided to call all images from the CSS files so that if an image needs to be changed, I only need to update the CSS file rather than each individual HTM ...

chart for visualizing two rows with matching IDs and dates

I have been attempting to accomplish the following two scenarios: 1) When both ID and dates are the same in the chart, but the descriptions differ, I want to display them on separate lines. 2) If there is not enough room to show the row label, I would li ...

Uploading Blobs using JavaScript and FormData

Currently, I'm encountering an issue with uploading a blob generated in JavaScript to my server. The main concept involves a user uploading an image, which is then center cropped and downsampled using JavaScript before being transmitted. Although the ...

How can I stack two appbar components from Material Ui on top of each other without the vertical line separating them?

I am facing a challenge while trying to incorporate two AppBar components in Material-UI, stacked one on top of the other. The problem arises when a line appears at the end of the first AppBar, overlapping with the second one. Click here to view an image ...

The z-index issue with Bootstrap modal is not being resolved on Firefox and Internet Explorer

I am encountering an issue with my bootstrap modal that includes a jquery datepicker. Specifically, the datepicker is styled as follows: .datepicker{ z-index:1000;} Interestingly, it functions perfectly on Google Chrome, displaying like this: However, ...

Incorrect posture during the movements

Utilizing Jquery Drag and Drop, I have implemented two swap-able divs. However, during the animation process of swapping the divs, their positions are not properly maintained. The actual swapping of the divs works correctly, but there is an issue with the ...

When using jQuery to enable contenthover on divs, they will now start a new line instead of

I've been working on achieving a layout similar to this, with the contenthover script in action: Mockup Draft Of Desired Look However, the result I'm getting is different from what I expected, it can be seen here. The images are not aligning co ...

Is the meta viewport exclusively meant for mobile phones?

Is it possible to configure the general responsive meta viewport setting specifically for phones? Our website appears fine on 7" and larger tablets in both portrait and landscape modes without the meta tag, but it is a bit inconvenient on smaller devices. ...

Averages of window sizes visible without scrolling

Most designers target browsers with a resolution of 1024x768, although widths of 960 - 980px are also acceptable. (Personally, I prefer 960 for the chrome, but that's just my preference.) My query is - what window height can we generally assume for u ...

Submitting the form does not result in the textbox being cleared

I have been attempting to clear the txtSubTotal text box upon clicking the PROCEED button, but it seems that my efforts have been in vain despite trying various code examples, including those from SO. btnProceed/HTML <input type="submit" name="btnProc ...

Including React components in my HTML documents

I have developed a node.js server using express and am rendering an html page with jsx code embedded. The server is running smoothly, but I am encountering difficulties when trying to import other jsx components into my html file to utilize them in my main ...

Is it possible to modify the background color of the firefox address bar according to the type of protocol being used?

Is there a way to customize the background color of the address bar in Firefox according to different protocols? For example, using blue for https, orange for mixed content warning, green for ev-certificate, and red for invalid certificates. ...

Looking to attach the "addEventListener" method to multiple elements that share the same class?

I'm trying to use an event listener in JS to handle the logic in the "onClick" function, but it's only executing once. I've applied the same class to all four buttons, so I'm not sure why it's only working for the first one. HTML: ...

Sending values from multiple input fields created in PHP using AJAX can be done by following these steps

https://i.sstatic.net/GKcRc.png Within this snippet, there is a portion of a form that consists of 4 different fields/divs like the one shown. I am struggling to figure out how to send the values of these input fields to PHP using AJAX. I apologize if ...

Achieve a left-aligned text section that remains centered using Bootstrap 4

I encountered a problem with bootstrap-4. I tried centering a section using the text-center class: <div class="text-center text-left"> <h2>Hi,I'm,</h2> <h2>Bonheur jed,</h2> <h2>Web Developer.</h2&g ...

Shift the position of an <img> downwards by 50% of its height while maintaining the flow of the elements

Consider this snippet of code below <div> <img src="http://www.lorempixel/100/200" /> <p> Bla bla bla bla </p> </div> I am trying to figure out how to move the image 50% of its height and also adjust the ...