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

Preventing jQuery from matching multiple elements

I'm currently working on implementing a rollover effect using jQuery. I've encountered an issue due to the fact that I'm trying to execute a mouseover event on an object containing a link. The specific scenario involves a level-2 navigation ...

An unexpected error has occurred in the browser console: The character '@' is not valid

I recently made the decision to dive into learning about Unit Testing with JavaScript. To aid in this process, I started using both Mocha.js and Chai.js frameworks. I downloaded the latest versions of these frameworks onto my index.html from cdnjs.com. How ...

What is the best way to synchronize the image dimensions and source when dynamically loading images?

I am facing an issue with a function that updates images by altering the src and css (width/height) of an IMG tag within the document. Below is a simplified example to demonstrate the problem: updateImage = function(src, width, height) { $("#changeMe"). ...

AngularJS: Solving the issue of controllers not exchanging data by utilizing a service

I am working with the following controllers and service: angular.module('myApp', []); angular.module('myApp').factory('ShareService', function() { var information = {}; information.data = ""; information.setD ...

The session becomes obsolete when redirecting back to the previous page

When attempting to redirect using the http referrer after storing a value in Session in php, I noticed that the Session becomes null. Is there a method to maintain the session even when utilizing the http referrer? ...

Insert the characteristics of the object into the header of the table, and populate the rows of the table

I have created an HTML table that displays specific object properties when the mouse hovers over a designated object. For example, hovering over the dog object will display the dog's name. I want to expand this functionality to also show the cat' ...

Make the div disappear upon clicking the back button in the browser

When a user selects a thumbnail, it triggers the opening of a div that expands to cover the entire screen. Simultaneously, both the title and URL of the document are modified. $('.view-overlay').show(); $('html,body').css("overflow","h ...

Encountering a problem within a Maven project during execution

Greetings, I am relatively new to maven and seeking some assistance. Recently, my Maven project has started displaying a 404 error on the browser when I attempt to run it. I initially created this Maven project using the webapp archetype and everything w ...

Display 1 row of content on larger LG screens and 2 rows on medium-sized MD screens using Bootstrap

How can I achieve 1 row with 12 cells on a large screen in Bootstrap, and for a smaller screen have 2 rows with 6 cells? Here is a visual representation of what I am trying to accomplish: https://i.stack.imgur.com/NgfaP.png This is the code I attempted: ...

Using JavaScript to toggle the visibility of grids depending on the radio button choice and then triggering this action by clicking on the search button

As a newcomer to AngularJS development, I am encountering some challenges while attempting to implement the following scenario. Any suggestions or guidance would be greatly appreciated. I aim to showcase either one or two Angular UI grids based on the rad ...

Unable to adjust the width of a datatable using the jQuery Datatable plugin version 10.1

I am facing a challenge with multiple datatables using the jQuery plugin on my page. Some of the datatables fit perfectly within the page width, while others extend beyond the page boundaries. Despite trying various methods, including setting styles in HTM ...

Loading a different webpage seamlessly without having to reload the current one

Here is a snippet of my code in okay.html: {% extends "sch/base.html" %} {% load staticfiles %} {% block content %} <div class="row" id="ada"> <form action="" method="post> {% csrf_token %} <div align="center" class="cont ...

Vertical alignment of content over image is not in sync

I am attempting to center my div container .home-img-text vertically in the middle of its parent div .home-img. Despite trying various methods such as setting .home-img-text to position: absolute, relative, adding padding-top, and several others, I haven&a ...

Embedding PHP script within HTML code can enhance website functionality and

I am completely new to PHP and have never worked with it before. I'm interested in running a PHP script from within an HTML file on a Linux system. Can anyone guide me through the process? Below is the code from my HTML file: <!DOCTYPE HTML PUBLI ...

Tips for increasing the dimensions of a modal in Bootstrap

<div class="popup zoom" id="_consultant"> <div class="popup-window " > <div class="popup-content" style="background-color:#F5F5F5" > </div> </div> </div> After extensive research, I have not found ...

The stacking order of a child element within a parent element, which has a transform

Hey there, I've encountered a problem and was wondering if you could assist me with it. In the code snippet provided below, you'll see that there are elements with: transform: translate(0,0); Within these elements, there is a "dropdown" elemen ...

Formcontrol is not functioning properly with invalid input

I am attempting to style an input field with a FormControl using the :invalid pseudo-class. Here is my code snippet: scss input:invalid { background-color: red; } html <input type="text" [formControl]="NameCtrl"> Unfortunate ...

Conflict with choosing options identified when using Select Box on IOS iPad mini

I am currently attempting to display a select box with scrolling on an iOS iPad mini. Issue: The options are not appearing inside the select box, instead they are overflowing outside of it in the popover. CSS .indicators_geography { font-size: 12px; ...

Tips for keeping a consistently viewable and editable iteration of your HTML form

How can I efficiently maintain both viewable and editable versions of the same HTML form? I am working on an application that has numerous custom data-entry screens with a high number of fields, and managing separate layouts for viewable and editable form ...

The menu shifts position or overlaps next to the current active menu option

It would be helpful to take a look at the URL provided (http://ymm.valse.com.my/) in order to understand my question better. Upon clicking on any menu item, I noticed that the menu next to the active tab overlaps. I believe the issue lies in the width pro ...