The art of arranging elements on a webpage using HTML and

I designed a rectangle using position: relative; and placed an icon inside it. However, when I added a new div class called .Home, and included an element <h4>Home</h4> with position: relative;, the element appeared outside of the rectangle. What am I missing?

I attempted to modify the position value, but the issue persists.

.container {
  height: 100%;
  width: 100%;
  margin: auto;
  display: table;
  top: 0;
  background-size: cover;
  position: static;
}

.Rec {
  width: 97px;
  height: 812px;
  left: 0px;
  top: 0px;
  background: #FFFFFF;
  box-shadow: 0px 4px 4px rgba(0, 0, 0, 0.5);
  position: relative;
}

.icons {
  position: relative;
  width: 38px;
  height: 48px;
  left: 30px;
  top: 29px;
}

.fa-bars {
  color: black;
  font-size: 30px;
}

.Home {
  width: 65px;
  height: 29px;
  left: 34px;
  top: 217px;
  font-family: 'Roboto';
  font-style: normal;
  font-weight: 500;
  line-height: normal;
  font-size: 20px;
  text-align: center;
  transform: rotate(-90deg);
  color: black;
  position: relative
}
<div class="container">
  <div class="Rec">
    <div class="icons"><i class="fas fa-bars"></i>
      <div class="home">
        <h3>Home</h3>
      </div>
    </div>
  </div>
</div>

Answer №1

Parent div does not need to be set as position:relative. Take a look at the Codepen example.

<div class="container">
  <div class="Rec">
    <div class="icons">
      <i class="fas fa-bars"></i>
      <div class="home">
        <h3>Home</h3>
      </div>
    </div>
  </div>
</div>

CSS

.container {
  height: 100%;
  width: 100%;
  margin: auto;
  display: table;
  top: 0;
  background-size: cover;
  position: static;
}

.Rec {
  width: 97px;
  height: 812px;
  left: 0px;
  top: 0px;
  background: #FFFFFF;
  box-shadow: 0px 4px 4px rgba(0, 0, 0, 0.5);
  position: relative;
}

.icons {
  width: 38px;
  height: 48px;
  left: 30px;
  top: 29px;
}

.fa-bars {
  color: black;
  font-size: 30px;
}

.home {
  width: 65px;
  height: 29px;
  left: 34px;
  top: 217px;
  font-family: 'Roboto';
  font-style: normal;
  font-weight: 500;
  line-height: normal;
  font-size: 20px;
  text-align: center;
  transform: rotate(-90deg);
  color: black;
  position: relative;
}

Does this meet your requirements?

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

Can the CSS be used to conceal the PNG image while still preserving the drop shadow effect?

I recently applied the "Filter: drop-shadow" effect to my png photo and it worked perfectly. However, I am now interested in hiding the actual png image while retaining the shadow effect. My initial attempt involved adjusting the translate and drop-shadow ...

Can someone explain how to implement an onclick event for a div element inside an iframe using jquery or javascript?

Understanding the HTML Structure <iframe src="#" scrolling="no" id="gallery-frame"> <div class="gv_filmstrip"> <div class="gv_frame"> <div class="gv_thumbnail current"> <img src="images/grandstand-padang-right/1.jpg"> </d ...

turning every input field's border to red if none of them were filled out at least once

I struggle with javascript and need some help. I have a form with multiple input fields, and I want to ensure that the user fills in at least one of them. I found code that triggers an alert message if the user does not fill in any fields, but I would pref ...

Scraping data from a website using Python by targeting the `<td

Just starting out with Python and Web Scraping... I'm trying to extract the numbers 1.16, 7.50, and 14.67 from the highlighted portion of code using td, class, table-matches__odds pageSoup.find_all, but so far haven't had any luck. Anyone have an ...

Adjust the appearance of self and other classes on hover using CSS

I'm looking for a way to use the :hover effect in CSS to change the font color of one class (.footer_status_tex) and the background color of another class (.footer_status_gear). Here's a simplified version of what I have in mind: CSS .footer_s ...

Firefox does not support event.dataTransfer.files for drag and drop operations

Currently, I am implementing drag and drop functionality into one of my projects and encountering an issue specifically with Firefox. The code I am using for testing purposes is as follows: document.getElementById("folder_files").addEventListener("drop", ...

The placeholder text is not displaying with bullets in Internet Explorer. However, it is functioning correctly in Chrome

I need assistance displaying the placeholder text in IE8 as shown below: "Any relevant reference numbers, such as Direct Debits: - Name of the Branch (if applicable) - What was the original problem - Date the problem occurred " While it appears correct ...

Optimizing the position of smart info windows in Google Maps

I am facing a challenge while attempting to switch the infowindow in Google maps to the smartinfowindow, as the position of the infowindow appears incorrect. This issue only occurs with the smartinfowindow and not with the standard infowindow. Upon furthe ...

Developing a JavaScript program that automatically updates the score in a Tic Tac Toe

I am currently working on developing a "Tic Tac Toe" game, but I have encountered an issue. Everything is functioning properly except for one aspect: when the game concludes and all squares are filled with either O or X, or when either X or O wins, it doe ...

Utilizing pixel values for Material-UI breakpoints rather than using the default sm, md, lg, xl options

Below is the code snippet that I am using: [theme.breakpoints.only('lg')]: {} The above code works perfectly and shifts at the desired breakpoint. However, when I implement the following: [theme.breakpoints.between('1200', '1021&a ...

The dropdown menus in Bootstrap are expanding outside the screen when opened

When I click on the dropdown in the Navbar on the right side, the menus open up far to the right and are not visible until I scroll horizontally. Here is the code snippet: <nav class="navbar navbar-expand-lg navbar-light bg-light"> < ...

Employing jQuery to save the href value as a fresh variable

There is an anchor tag with id 'item-1' that needs to be stored in a new variable called 'href'. The tag looks like this: <a id='item-1' href='#something'> To achieve this using jQuery, what approach should be ...

Ways to enhance a browser's response with soup

I have a script that sends multiple requests to a website using RoboBrowser and retrieves responses, but now I need to filter these responses to exclude any containing the phrase "Case Status Not Available". I attempted to use Beautiful Soup for this purpo ...

Transformation of a double-row header

Click here to view the design - two-row header image I'm struggling with creating a header design that consists of two rows - the first row includes a centered logo and icons on the right side, while the second row contains the menu. Can someone guid ...

What are the steps to implement infinite scrolling in a Vue.js application?

Currently, I am attempting to implement an infinite horizontal scroll section in vuejs for a selection of products. However, I am facing difficulties achieving the infinite effect. My approach so far involved removing the card that goes out of view and add ...

What could be causing this strange striping effect in the radial gradient?

What causes the striped effect in the radial gradient code provided on this website: click here to view body { background: rgba(216,215,221,1); background: -moz-radial-gradient(center, ellipse cover, rgba(enter code here216,215,221,1) 0%, rgba(0,9 ...

When a <dl> element is nested within an <ol>, it will be rendered as a list format

I'm facing an issue with my CSS that affects how different browsers render definition lists embedded within ordered lists. In IE10, the list displays as expected - a bulleted list inside the ordered list without affecting the numbering. However, Firef ...

Tips for creating a captivating full-screen parallax section on your website

Is there a way to make the first section of a parallax site full screen? I've been scouring the internet for a solution to this problem, but I'm not having any luck. Almost every parallax site I come across has their first section full screen, a ...

Use the same CSS style for various attribute selectors

Is there a way to simultaneously apply the following style to a type="submit" without having to repeat the entire block of code? input[type="button"] { width: 120px; margin-left: 35px; display: block; } ...

Creating a personalized LinkedIn share button through POST requests: here's how

I am interested in using my own image for the LinkedIn share button. After referencing a previous post on this topic: How to make a custom LinkedIn share button It was mentioned that: In order to create a custom Share button for LinkedIn, POST calls need ...