Different methods for concealing the display of CSS grid-area names

Currently, I am in the process of creating a user interface using CSS grid layout and HTML. The design involves numerous grid rows and columns.

The structure of my CSS and HTML code is illustrated below:

<!DOCTYPE html>
<html>
  <head>
    <meta charset="UTF-8">
    <title>WP Desktop</title>
<style>


html, body, .grid-container { height: 98%; margin: 2; }

.grid-container * { 
 border: 2px solid blue;
 position: relative;
}

.grid-container *:after { 
 content:attr(class);
 position: absolute;
 top: 0;
 left: 0;
}

.grid-container {
  display: grid;
  grid-template-columns: 1fr 1fr 1fr 1fr 1fr;
  grid-template-rows: 1.8fr 0.2fr 1fr;
  grid-template-areas: "プロジェクトビュー Design-Area Design-Area Design-Area Outline" "プロジェクトビュー Design Source Others Outline" "プロジェクトビュー Terminal Terminal Terminal Properties";
}

.プロジェクトビュー { grid-area: プロジェクトビュー; }

.Design-Area { grid-area: Design-Area; }

.Design { grid-area: ""; }

.Source { grid-area: ""; }

.Others { grid-area: ""; }

.Terminal { grid-area: Terminal; }

.Outline { grid-area: Outline; }

.Properties { grid-area: Properties; }


</style>

  </head>
  <body>
    <div class="grid-container">
      <div class="プロジェクトビュー"></div>
      <div class="Design-Area"></div>
      <div class="Design" ><button id="btndesign" > Design  </button></div>
      <div class="Source"><button id="btnsource"> Source  </button></div>
      <div class="Others"><button id="btnothers"> Others  </button></div>
      <div class="Terminal"></div>
      <div class="Outline"></div>
      <div class="Properties"></div>
    </div>
  </body>
</html>

In the given Div class tags, there isn't any text provided, yet the grid displays test Design-Area.

I'm still learning about CSS and HTML, so I would like to know how to remove this displayed text.

Kindly assist me with this issue as I continue exploring CSS and HTML features.

Note: Updated with complete code snippet

Answer №1

.grid-container *:after { 
 position: absolute;
 top: 0;
 left: 0;
}

Let's adjust the code by removing the content:attr(class); property from the class above. This change will prevent your classname from being displayed in the grid area.

Answer №2

The issue lies within your CSS code, specifically in the section where you are displaying the attribute as the content of the box, which may not be your desired outcome:

.grid-container *:after { 
 content: attr(class);
 position: absolute;
 top: 0;
 left: 0;
}

If you remove this part of the code, it should resolve the problem of unwanted text appearing in your layout.

Answer №3

Unless specifically inserted, the test Design-Area will not be displayed. Therefore, you can simply remove the text.

.grid {
  display: grid;
  grid-template-areas: "Design-Area area-two";
  grid-template-rows: 1fr 1fr;
}

.Design-Area {
  border: 1px dotted grey;
  grid-area: Design-Area;
}

.area-two {
  border: 1px dotted grey;
  grid-area: area-two;
}
<div class="grid">

  <div class="Design-Area"></div>
  <div class="area-two"> Here is text, Design-Area has no text </div>
</div>

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

Using Jquery's closest technique to target a class located outside of the parent div

I am having trouble accessing a class outside of its parent div $(document).on('click', '.delete_photo', function(event){ var del_id = $(this).attr('id'); $.ajax({ type:'POST', cache: false, url:&apo ...

Preventing React callback refs from exposing class methods externally

In the task at hand, I am required to create a React component for displaying toasts that hide by themselves and show from outside. Most guides on React focus on how to access the DOM from a React component, but there is little information available on how ...

Issues with the functionality of CSS Modules and hover styles_integration

After creating a react web-app with a custom build - including webpack, webpack-server, typescript, image-loaders, css, scss, and css-modules - I encountered an issue with CSS pseudo elements. The hover effect is not working as expected. .image { height ...

Creating a dynamic JSTree that loads data on demand using Stored Procedures

Currently in my SQL Server database, I have two Stored Procedures that are responsible for extracting data from a tree structure: One procedure retrieves all nodes at a specific level based on the provided level number. The other procedure retrieves th ...

Strategically placing an element under a canvas using HTML and CSS

The challenge I'm facing is positioning the experience section beneath the canvas and title elements. However, it seems like the experience section is overlapping the canvas. Despite trying to increase the left margin, I am still unable to resolve thi ...

Incorrect Calculation of CSS Grid Container Width in Firefox

When using this CSS Grid code, there is a difference in behavior between Chrome and IE compared to Firefox. https://codepen.io/inkOrange/pen/XGzeMo This layout is intended to scroll horizontally when the content overflows beyond the fixed container size o ...

Using CSS to justify the final line of content

I have created a CSS helper class that is meant to justify-align the last line of text, or inline block divs, along with the rest of them. Here is the CSS code I have implemented: .justify-all-lines { text-align: justify; /* IE-only properties th ...

Jest fails to recognize environment variables, even when using --setupFiles dotenv/config

I have been encountering an issue while writing tests for my Express project. It seems that when I run the test script, my environment variables are not being loaded properly. After looking into other discussions, I tried using --setupFiles dotenv/config, ...

Personalizing the placement of FontAwesome markers on an Image (map) with absolute positioning

I have successfully positioned markers on a map using FontAwesome to ensure they maintain their relative position when the map is resized. Currently, each marker consists of a number inside a circle created with FontAwesome. However, I am interested in ut ...

unique design for custom scrollbar on dropdown menu

I'm looking to customize the scrollbar for a select box. I've experimented with the code below, but I want to avoid using the default scrollbar on the select box. Instead, I want to implement a custom scrollbar without using the size attribute on ...

Formulate a CANNON entity utilizing the THREE.Mesh technique

I have a THREE.js plane where the points are manipulated using Perlin noise to create terrain. I now need to implement physics for the camera to prevent it from falling through the plane. My goal is to develop a function that can extract the vertices and ...

Adding an image to an HTML <span> element using the class attribute "

I need help adding an image to my HTML code. For example, how can I specify which image should be displayed in place of the placeholders? Thank you for your assistance! ...

Should font size, line height, and font-family be declared to the body before or after the CSS reset?

Let's say I am using the Eric Meyer Reset and I need to apply a style to the body element. body { font: 100%/1.5 "Helvetica Neue", Helvetica, Tahoma, Arial, sans-serif;*/ } Should I place this before or after the reset CSS? html, body, div, span, a ...

What is the best way to combine two nearly identical arrays/objects using underscorejs or a similar library?

In the realm of lists, there exists an old list and a new one. The mission at hand is to combine both, even in the presence of newly added key-value pairs. var oldList = [{ id: 1, name: 'Michael', sex: 'male', goodlooking: 1 }, ...

Building interactive forms in Angular 6

I want to design a dynamic form that creates a new form when the AddNew button is clicked. In my TypeScript (ts) file, I have the following code: addinfoForm: FormGroup; infoNameList: FormArray; infoModel: Productdetail; constructor(private fb ...

Seamless AJAX Uploads: Proceeding without pausing for a response

Currently, I am utilizing Blueimp's jQuery Uploader along with an S3 handler to successfully upload files and transfer them to S3 via the S3 API from the PHP SDK. While this setup works well, the issue arises when dealing with large files, particular ...

How should elements be properly inserted into injected HTML code?

We are currently phasing out our custom forms in React on the website, and transitioning to Microsoft Dynamics 365 generated forms. These new forms are injected through a React placeholder component created by a script that loads the js bundle and inserts ...

React material ui is not compatible with custom styles that are applied to components

I've developed a unique UserIcon Component that showcases an icon along with accompanying text. Take a look at the code snippet below: import React from "react"; import PropTypes from "prop-types"; import { withStyles, Avatar, Typography } from "@mat ...

Updating the names of keys within an object that includes nested child objects

I am looking to update the keys in an object that contains nested objects with similar structures. Initially, my object looks like this: objs = { "one":{ "title":"bla", "amount":5, "children":[ { "title":"bla", ...

Inject the variable into location.href

I am dealing with a dynamic URL, and I want to achieve the following in my HTML: <a onclick="location.href='myVariable';"><span>Click here</span></a> The issue is that this approach displays the actual string 'myVar ...