Header getting shoved aside

My header functions flawlessly in its own HTML file, and the product details page is also perfectly fine on its own. However, when I combine the two by adding the header to the product page, it completely messes up. It pushes the header out of place, causing part of the product details to appear on the right side of the header.

Even after using inspect element, I couldn't find any padding or margins that could be causing this issue. Adding margin or padding manually also didn't resolve the problem.

I suspect that there might be an issue with the product page itself because inspect element highlighted that section of the page during troubleshooting.

Any assistance would be greatly appreciated!

Some of the product HTML (https://i.sstatic.net/tsGDT.png)](https://i.sstatic.net/tsGDT.png)

PRODUCT HTML:

@import url(https://fonts.googleapis.com/css2?family=Rubik:wght@100;200;300;400;500;600;800;900&display=swap);

* {
    margin: 0;
    padding: 0;
    font-family: 'Rubik', sans-serif;
    box-sizing: border-box;

}

html {
    scroll-behavior: smooth;
}

.small-container{
    max-width: 1000%;
    margin: auto;
    padding-left: 25px;
    padding-right: 20px;
    
    

}
.row{
    display: flex;
    align-items: center;
    flex-wrap: wrap;
    justify-content: space-around;
    
    

}
.single-product{
    margin-top: 80px;
    
}
... (CSS code continues)
  
 </body>
</html>

PRODUCT CSS:

Product page on its own (https://i.sstatic.net/Vnd9J.png)](https://i.sstatic.net/Vnd9J.png)

Header on its own (https://i.sstatic.net/eQE3g.png)](https://i.sstatic.net/eQE3g.png)

The combination of both the header and the product details (https://i.sstatic.net/9y2t1.png)](https://i.sstatic.net/9y2t1.png)

I attempted to find any disruptive padding and margins.

In addition, I tried adding padding and margins to the smallcontainer and row in the CSS.

Answer №1

When both your header and product page are enclosed in a .row element, the expected behavior is quite normal (as a row is designed to handle its contents vertically). Learn more here

You have two options: either remove the .row wrapper or replace it with a .col element.

.col{
 display:flex;
 flex-flow:column;
}

Answer №2

It appears that there may be a float issue in your code. Floats are being used without any clearfixes, which could potentially lead to unexpected behavior.

My suggestion is to limit the use of floats to situations where text needs to wrap around another element and consider utilizing flexbox more frequently for better control over layout.

In an effort to troubleshoot, I removed the float from the code and made adjustments: view full code on CodePen

Modified CSS:

(CSS code provided here)

I have indicated the changes with comments in the modified CSS. Additionally, I noticed another error in the code related to a missing unit for padding.

If the issue persists, it might be worthwhile to review JohnSs answer, as there could be a container with display: flex; surrounding the problematic section and an incorrect flex-direction setting as highlighted by him.

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

Elevate Your Designs: A New Perspective on Vertical Alignment

I am struggling to vertically align my text, which spans multiple lines, while implementing the scroll-over effect. I attempted to include vertical-align: middle; in my code, but unfortunately, it did not produce the desired result. Here is my CSS code: ...

Is there a reason why the Chrome browser doesn't trigger a popstate event when using the back

JavaScript: $(document).ready(function() { window.history.replaceState({some JSON}, "tittle", aHref); $(window).bind("popstate", function(){ alert("hello~"); }); }); Upon the initial loading of the www.example.com page, the above JavaScript code is ex ...

Saving HTML content into a MySQL database using Python

I have the task of storing locally stored crawled HTML pages. I successfully open the file using myHTML = open(file_location,'r').read() output can be found here: I am able to create the SQL query successfully: query_insert = ("insert into jo ...

The extent of a nameless function when used as a parameter

I am currently developing a straightforward application. Whenever a user hovers over an item in the list (li), the text color changes to green, and reverts back to black when the mouse moves away. Is it possible to replace lis[i] with this keyword in the ...

Determine whether an element possesses the rel="nofollow" attribute by utilizing CSS in Selenium test cases

In my Selenium test scripts, I am utilizing CSS selectors as element locators. Currently, my goal is to verify whether an element contains the attribute rel="nofollow" using CSS. Does anyone have insight on how to accomplish this task? ...

Choosing Issues

My selectpicker is displaying data outside the dropdown menu before making a selection. The data appears both inside and outside of the dropdown. Can someone please help me identify the issue and guide me on how to fix it? <select class="selectpick ...

Customizing the scrollbar within a modal using reactjs-popup

I am currently working on a CustomPopup functional component that includes a reactjs-popup: function CustomPopup({setFalse, item}){return(<Popup open={true} onClose={() => {setFalse(false)}} modal closeOnDocumentClick nested> {item === "howto ...

Verify that all the input values within the class are empty using jQuery

Within this section, I have multiple input text fields all sharing the same class: <input type="text" class="MyClass"></input> <input type="text" class="MyClass"></input> <input type="text" class="MyClass"></input> My ...

Adjusting the width of individual cells or columns within a table through my HTML code is proving to be a challenge

I am struggling to adjust different column widths in my table. Despite trying various approaches, such as changing the width of specific td/th elements and using inline styling or nth-child property, I have been unsuccessful in altering the width. The tabl ...

How can you attach a d3 graphic to a table that was created automatically?

Calling all experts in d3, I require urgent assistance!! On this web page, a JSON is fetched from the server containing 50 different arrays of numbers and related data such as 90th percentiles, averages, etc. A table is dynamically created with the basic ...

Troubleshooting problem with spacing on three horizontal divs

I am currently working on building an E-commerce website to gain some practice. Here is how the div is set up: .small-container { max-width: 1080px; margin: 5px; padding-left: 25px; padding-right: 25px; } .col-4 { flex-basis: 25%; padding ...

The navigation bar triggers the opening of all icon menus in their designated positions at the same time

This code snippet represents the navigation bar for an admin user, featuring 3 icons: navigation menu, user menu, and manage button icons. The problem arises when clicking on any of these icons, as all dropdown items from each icon are displayed in their ...

"Discovering IFrames on the fly with Selenium and Java: A step-by-step

My application automation is posing a challenge as the IFrame id and name keep changing dynamically, making it difficult to uniquely identify the Iframe element. The HTML snippet of the Iframe in question shows that the name is currently "tvcTabs0_c340cont ...

Is it possible to execute JavaScript within an Android application?

Is there a way to utilize the javascript provided by a website on an Android device to extract and analyze the emitted information? Here is the javascript code: <script type="text/javascript" src="http://pulllist.comixology.com/js/pulllist/5b467b28e73 ...

Dropping challenging shapes in a block-matching game similar to Tetris

I'm currently working on a game similar to Tetris, but with a twist. Instead of removing just one line when it's full, I want to remove all connected pieces at once. However, I've run into a roadblock when trying to implement the hard-drop f ...

What is the best way to horizontally align a button with CSS?

I need help with positioning a button on my web page. The button looks great, but it's currently off to the left and I want it centered below the main text. Any suggestions on how to achieve this? <!DOCTYPE html> <html lang=""> <head& ...

Issues with displaying Bootstrap 5 second toast notifications

Hey there, I'm facing an issue with getting the second toast to display properly. Here is the HTML: <div class="toast-container position-fixed bottom-0 end-0 p-3"> <!-- FIRST --> <div class="toast" role="aler ...

Show HTML content retrieved from a JSON response

I have developed a basic system that retrieves data from my JSON file instead of relying on a database. The functionality works well, however, I am encountering a problem with the html tags being displayed as plain text. It's important to mention that ...

Unable to dispatch the form on a connected page using jQuery Mobile

I have encountered an issue while trying to submit a form using jQuery Mobile. The problem arises when the form is placed on a linked page, as it fails to submit properly. To illustrate, if my home page is mysite.com/page.html, placing the form code on tha ...

Combining text and images in XSLT using CSS: A comprehensive guide

Greetings! I am facing a situation where I have an XML file containing image tags like this: <pb facs="ciao.jpg">. Additionally, I have an XSL file that includes a JavaScript snippet as shown below: <script type="text/javascript> function ...