What causes my image to overlap my navigation bar when I rotate it?

Is there a way to rotate images in CSS without causing them to overlap with other elements on the page? When I try to adjust the rotation property, the image sticks to the top of the page and overlaps the navigation bar.

Below is the code snippet:

HTML Code Block

<!DOCTYPE html>

<html lang = "en">

<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0"> 
    <Title>OTF Official Website</Title>
    <link href = "OTFstyle.css" rel = "stylesheet">
    <script src = "OTFscript.js"></script>
</head>

<body>
    <div class = "header">
        <img src = "icons/otflogo.png" alt = "Logo" id = "logo">
    </div>

    <div class = "toolbar">
    
        <div class = "home">
            <img src = "icons/home.png" alt = "Home" id = "homeicon"> 
            <p id = "text">Home</p>
        </div>
        
        <div class='ppl'>
            <img src="icons/ppl.png" alt="Members" id="personicon">
            <p id="text">Members</p>
        </div>

        <div class="cam" >
             <img src="icons/cam.png" alt="Pics and Videos" id="camicon">
            <p id="text2"> Pics</p>
        </div>

        <div class = "mem">
            <img src="icons/mem.png" alt="Memories" id="memoryicon">
            <p id="text3"> Memories</p>
            
        </div>
    </div>


    
    <div class="intro">

        <img src="frames/frame1.png" id='frame1'>
        <img src="frames/frame2.png" id='frame2'>

        
             


    </div>
    
</body>

</html>

CSS Code Block

/*Entire pg*/
html,body{
    background-color: rgb(144, 141, 141);
    margin: 0;
    padding: 0;
    width: 100%;
    
    
}
body{
    height:1000px;
}

/*Div containing the header*/
.header{
    border:solid;
    height:80px;
    display:flex;
    background-color: whitesmoke;
}
/*otf logo*/
#logo{
    object-fit: cover;
    width: 120px;
    height: 120px;
    margin-top:-20px;
}

/*Div containing the entire toolbar*/
.toolbar{
    top:0px;
    position:sticky;
    height:60px;
    display:flex;
    justify-content: space-evenly;
    background-color: wheat;
}
/*Div containing Home icon*/
.home{
    display:block;
    height:60px;
    justify-content: center;

  
}

/*Div containing members icon*/
.ppl{
    display:block;
    height:60px;
    justify-content: center;
}

/*Div containing members icon*/
.cam{
    display:block;
    height:60px;
    
    justify-content: center;
}

/*Div containing memories icon*/
.mem{
    display:block;
    height:60px;
    justify-content: center;  
}

/*The icons themselves in the toolbar*/
#homeicon{
    height:40px;
}
#personicon{
    height:40px;
}
#camicon{
    height:40px;
}
#memoryicon{
    height:40px;
    margin-left:11px;
}
/*Text under home and members icon*/
#text{
    margin-top:0px;
}
/*Text under pics icon*/
#text2{
    margin-top:0px;
    margin-left:15px;
}
/*Div containing memories icon*/
#text3{
    margin-top:0px; 
}

/*Div containing the images*/
.intro{
    border:solid;
    display:block;
    background-color: white;
    
}

/*First image*/
#frame1{
    height:300px;
    rotate:50deg;
    
}
/*Second image*/
#frame2{
    height:300px;
    margin-left:-100px;
}


I tried rotating an image using CSS, but it caused overlapping issues with other elements on the page. Any suggestions or solutions would be greatly appreciated. Thank you!

Answer №1

If I understand your explanation correctly, it seems like you are looking to adjust the z-index property of your

<div class="toolbar">
so that it appears above the images.

In this example, I have set the z-index of the .toolbar to a value of 9999, ensuring it is positioned higher than the images themselves: https://jsfiddle.net/an5m2eqs/

Take note of how the z-index values for the toolbar and images are carefully selected to stack them in the desired order:

/*Div containing the entire toolbar*/
.toolbar {
  top: 0px;
  position: sticky;
  height: 60px;
  display: flex;
  justify-content: space-evenly;
  background-color: wheat;
  z-index: 9999;
}

To delve deeper into the intricacies of z-index, refer to this helpful resource: here.

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

What is the best way to position a box in the center using CSS?

I have constructed a container using div and included 4 additional div elements inside: HTML: <div className='main__container'> <div className='item'>Image</div> <div className='item'>N ...

Generate a separate div element for each row within a table structure

I currently have a table within my HTML code. My goal is to generate a new div for each row in the table. Each div should contain a <p> element corresponding to the data in the first and second columns of each row. Is there a way to accomplish this ...

Is there a way to populate two mysql tables using just one textarea input?

Hello, I'm currently working on my "Add Blog Post" page where I would like to make a change. Specifically, I want to eliminate one textarea (the post description area) and have the content entered in the Post Content textarea populate both the post de ...

Bootstrap sticky footer with adjustable height

Striving to achieve a sticky footer with a custom height on my website has turned out to be more challenging than I initially expected. Presented below is a snapshot of the current state of my footer: The issue arises where my contact form is concealed b ...

Adding color dynamically to text within ion-card based on a regex pattern

My goal is to enhance the appearance of certain text elements by wrapping them in a span tag whenever a # or a @ symbol is detected, creating the look of usernames and hashtags on Twitter. Below is the code I am currently using: TS FILE: ngOnInit(): void ...

Using @Input to pass data from a parent component to a

Looking to modularize the form code into a separate component for reusability? Consider using @Input and referencing it in the HTML to pass values to the post method. Here's how you can achieve this: Previously, everything worked smoothly when all th ...

The collapsible hamburger navbar is unresponsive and fails to collapse

Currently, I am working on a project that requires my navigation bar to be scaled down to a hamburger menu for mobile view. I have managed to do most of it, but for some reason, the navigation is not collapsing within the hamburger bar. I have been tweakin ...

This webpage is optimized for all browsers, with the exception of the Android Browser that may display fonts with larger sizes

When developing my webpage, I made sure it was compatible with all major browsers and even optimized it for mobile browsers. However, I overlooked testing the page on Android browser (specifically Android 4.2) and encountered some issues. The viewport set ...

An innovative tool for discovering how different colors will complement each other

Design may not be my strong suit, but there are times when I need to add a border line or a shade of gray to a background color. Is there a tool available where I can specify background color: #343434 color: #asdfgh and visually see how it will look wit ...

Altering data in a concealed dynamic HTML form

I have a hidden form on my webpage that gets populated dynamically when a button is clicked. I want to be able to change the values within this form dynamically. Initially, the form looks like this: <form id="zakeke-addtocart" method="pos ...

Error encountered in jQuery's addClass and removeClass functions: Unable to read the property 'length' of an undefined value

Upon loading my page, I aim to have some of the div elements hidden initially and display only one. Here is a script that accomplishes this goal: <script> $(document).ready(function () { $(".total").click(function () { $("#pi ...

CSS: Breaking free from the constraints of a Bootstrap-inspired grid layout

Looking to create a template with a background on the left side that extends to the edge of the page within an 8 of 12 bootstrap columns setup. The remaining 4 columns on the right will not have a background. This layout should be responsive, stacking on t ...

The Hover Hover textbox stays in place once clicked on

I have implemented a search bar that displays a textbox when a user hovers over a button. I am looking to modify the code so that the textbox remains visible even after the user has clicked on it. This way, if the user accidentally moves their mouse away f ...

Present information from a list in a table format

My webpage contains a single table where I want to showcase an image in row1 along with its details. As each image is displayed, its corresponding details are added to a list. There are a total of 27 images spread across 9 rows in the table. Once all the ...

Is there a variation in HTML/XHTML/XML code based on different geographic regions?

I have a question regarding the consistency of HTML, XHTML, and XML code across different localizations. If I write code on a system using the "en-us" localization, will it remain the same when rendered on a system with the "sv-SE" localization? For examp ...

Modifying the appearance of the login field shown in the image

How can I align the login and password fields in the same order on my webpage? When I attempt to adjust their positions using CSS margin commands, both fields end up moving. Any suggestions? ...

Display a full-width card beneath each small card in every row using CSS

In a scenario where I have designed a layout consisting of 3 column/row cards across multiple rows. Each card displays basic information, and when a user clicks on any specific card, a full-width card below that row will display more detailed information. ...

incorporating numerous interconnected javascript files within a single html document

I have a pair of JavaScript files (file1, file2). File1 utilizes a class that is defined in file2. Can I include these files in an HTML document like this: <script type="text/javascript" src="file1.js"></script> <script type="text/javascrip ...

How to make Firefox create a new line in a contenteditable field

I am working with a contenteditable div that is within a parent div with a floating width of 50%. My goal is to set the max width of the content editable to match the container, even if the text spans multiple lines. Here is the CSS I tried: .editable-con ...

Is the HTML5 capture attribute compatible with wkwebview?

Is it supported as stated in the title? For more information, you can check out the MDN documentation (Incomplete) and the Caniuse list of supported browsers. Surprisingly, none of them mention wkwebview. Does this attribute have support in wkwebview? Kno ...