The creation of a dot using span in CSS is not produced by React

I want to create a component that includes a dot between two elements. I've tried using the span element with CSS to display a dot between the spans, but React isn't generating the dot. Using a div does display the dot, but the formatting of the two elements isn't centered properly.

//html
import "./styles.css";

export default function App() {
  return (
    <div className="panel-section">
      <div className="panel-header">
        <div className="panel-title">
          {/** The div format is incorrect */}
          <div>May 1st 5:31PM</div>
          <div className="panel-dot"></div>
          <div>Google</div>
          {/** The dot is not generated 
          <span>May 1st 5:31PM</span>
          <span className="panel-dot"></span>
          <span>Google</span>
          */}
        </div>
      </div>
    </div>
  );
}


//css
.panel {
  width: 600px;
  height: 500px;
}

.panel-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  left: 0.5%;
  right: 33.44%;
}

.panel-title {
  padding: 8px;
  color: #ffffff;
  background-color: #3aac6f;
}

.panel-dot {
  width: 4px;
  height: 4px;
  background: #3aac6f;
  align-self: center;
}

Check out this CodePen for more:

Answer №1

Give this a shot:

Main.js

import React from 'react';
import './style.css';

export default function Main() {
  return (
    <div className="panel-section">
      <div className="panel-header">
        <div className="panel-title">
          <span>June 5th 10:08AM</span>
          <span>Netflix</span>
        </div>
      </div>
    </div>
  );
}

style.css

.panel-title span:first-of-type::after {
  content: '-';
}

Preview : Stackblitz

OR

Main.js

import React from 'react';
import './style.css';

export default function Main() {
  return (
     <div className="panel-section">
       <div className="panel-header">
         <div className="panel-title">
           <span>June 5th 10:08AM</span>
           <span>{"-"}</span>
           <span>Netflix</span>
         </div>
       </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

Exploring the World of Html

I'm struggling with an HTML problem related to a web programming class I'm taking. The assignment involves creating a video game using HTML and JavaScript, where an image moves randomly on the screen and the player must click on it as many times ...

Client failed to receive the message that was sent through socket.on(...)

Upon checking, it appears that the message was successfully sent to the server: https://i.sstatic.net/kHu5l.png // Function used in ReactJS (client) const sendMessage = () => { const data = { room: room, content: { author: userName, ...

html div elements may not align correctly

Currently, I am in the process of coding a website that contains numerous images. To assist me in organizing and arranging these images, I have turned to angularjs. Initially, everything was progressing smoothly until this issue arose: https://i.sstatic. ...

Tips for customizing the md-select icon

I work with the angular-material framework and specifically utilize its <md-select/> component. I am interested in styling its icon: https://i.stack.imgur.com/g4pu1.png In the past, we would modify its css by targeting the class .md-select-icon, ...

Encountering a Project Oxford error - HTTP 404 while trying to access Computer Vision API with Javascript

I am attempting to retrieve JSON data from Microsoft Project Oxford via an API call. Despite following the API reference, I encounter a 404 error when making the call. <script src="http://ajax.googleapis.com/ajax/libs/jquery/1.9.0/jquery.min.js">< ...

What could be the reason for the failure of calling a function within an object using "this.myFunction"?

Reviewing these two code snippets, I am faced with a puzzle. The first code block fails to execute, while the second one successfully runs. This has left me perplexed, and I am seeking clarification from those who can shed some light on the matter. [My cu ...

flexible style class in css

Currently, I am facing an issue where I need to display a variable number of items with a uniform margin setting that changes across the set. In simple terms, if I have a set like [1,2,3,4,5], it would look like this: 1 2 3 4 ...

Can ngAnimate facilitate conditional transitions?

In my application, I have set up an animation using ngAnimate on ngView where the next view slides in from the right every time there is a state change. Now, I want to be able to reverse this behavior so that sometimes the view slides in from the left (fo ...

Istio - Directing traffic for multiple React applications through a single virtual service

Two frontend express static react apps need to be routed accordingly. One should be accessible at the root, while the other at /provider. Currently, the route to /provider is not displaying the static content, although it works for the root. apiVersion: n ...

The value being passed to the JavaScript function remains constant and does not undergo any

I'm currently working on a new feature that allows users to report comments on the site. I've set up a PHP function in a PDO class for this purpose. When a user clicks on 'report,' a JavaScript function is triggered using Ajax to call ...

`store and utilize the data retrieved from chrome.sync.storage.get()`

As I work on a Chrome extension, I am facing an issue with retrieving information from chrome.storage. This involves saving some data in the options page and then accessing it in the content_script. In the options.js, this is how the information is saved: ...

Tips for dynamically displaying images in both horizontal and vertical orientations

I would like to showcase images in the imageList. Here is what I want: AB CD How can this be achieved? It's not a matter of being even or odd Perhaps the list could look something like this: ABCDE FG I simply want a new row or display:block when ...

Using Bricklayer.js multiple times on one page: a guide

UPDATE I have incorporated @Alice's solution into this code snippet to demonstrate the purpose of using bricklayer. While working with bricklayer, I noticed that it only affects the first bricklayer and ignores the second one. This behavior is expecte ...

Encountering issues with socket.io. Unable to establish connection. The front end indicates "connection: false" while the backend does not record any activity

I am having trouble setting up a connection between my react app and socket.io. Here is my code in app.js file: const express = require('express'); const port = process.env.PORT || 4000; const router = require('./routes/routes'); const ...

Is there a way to automatically scroll the page to the main content as soon as the user begins scrolling?

On my website, I want to have a full-screen image at the top followed by the main content right below it. I am looking for a way to automatically scroll the page down to the main content as soon as the user starts scrolling. How can I achieve this using ...

Running a bash command within a Node.js application while having root privileges

There is a slight issue that I'm encountering. I have a nodejs app that needs to execute a command in the OS's bash with root privileges, for example: The command is: echo "$password" | /usr/bin/sudo /usr/bin/abc --key "$username" Below is my c ...

When the month picker is selected, my intention is to retrieve the true value. However, I am encountering an issue where it consistently returns the false value instead

I created a month picker similar to the image provided. After removing unnecessary code, I was left with only the part that generates questions. Initially, when the month picker renders, no value is selected. However, upon selecting a month, the value is d ...

Sophisticated CSS design featuring a heart-shaped cutout from the background

I am trying to design a shape using only CSS (no images) that is the opposite of a heart shape. It's a bit hard to explain, so here is a visual representation: The blue represents the background, but the shape I am aiming for is not a heart, it is ac ...

Issue with Flask form submission in a specific scenario but functioning correctly in a different context

I'm currently working on a flask website, and I'm facing an issue with the SubmitField not functioning when I click it. I tried a similar method with a smaller form and it worked, but for this specific case, it's not working. routes.py from ...

Updating the HTTP request header in AngularJS without requiring a page refresh

I'm in the process of developing a website that utilizes ngRoute for page navigation. When a user logs in, a form will appear and upon successful login, the controller will modify the http header for subsequent requests. However, I am encountering an ...