In search of assistance in designing a simple baseball bases illustration

I am working on creating an indicator to identify which bases have a person on them. Utilizing Bootstrap React's Container, Row, and Col for positioning, I have also designed my own CSS classes for the triangles. However, I am facing a challenge in getting them to connect with each other to form a diamond shape for the base. I am open to exploring alternative methods to achieve this.

Current Output

https://i.sstatic.net/EIHC1.png

Desired Output

https://i.sstatic.net/HjC9a.png

My Components Container

<Container>
  <Row>
    <Col sm="auto">
        <div className="triangle-blank"></div>
        <div className="triangle-left"></div>
    </Col>
    <Col sm="auto">
        <div className="triangle-left"></div>
        <div className="triangle-right"></div>
    </Col>
    <Col sm="auto">
        <div className="triangle-right"></div>
        <div className="triangle-left"></div>
    </Col>
    <Col sm="auto">
        <div className="triangle-blank"></div>
        <div className="triangle-right"></div>
    </Col>
  </Row>
</Container>

My CSS classes

.triangle-left {
  width: 0;
  height: 0;
  border-top: 20px solid transparent;
  border-right: 25px solid #555;
  border-bottom: 20px solid transparent;
}

.triangle-right {
  width: 0;
  height: 0;
  border-top: 20px solid transparent;
  border-left: 25px solid #555;
  border-bottom: 20px solid transparent;
}

.triangle-up {
  width: 0;
  height: 0;
  border-left: 20px solid transparent;
  border-right: 20px solid transparent;
  border-bottom: 25px solid #555;
}

.triangle-down {
  width: 0;
  height: 0;
  border-left: 20px solid transparent;
  border-right: 20px solid transparent;
  border-top: 25px solid #555;
}

.triangle-blank {
  width: 0;
  height: 0;
  border-top: 20px solid transparent;
  border-left: 25px solid transparent;
  border-bottom: 20px solid transparent;
}

CodeSandbox Link

Answer №1

Can SVG be utilized?

<?xml version="1.0" encoding="UTF-8"?>
<svg xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" width="100%" height="100%" viewBox="0 0  640 200" preserveAspectRatio="xMinYMin meet">
   <rect id="svgEditorBackground" x="0" y="0" width="640" height="200" style="fill: none; stroke: none;" />
   <g id="e4__group">
      <path d="M-35.815383,-37.476921l-4,4l4,4l4,-4Z" style="fill:white; stroke:black; vector-effect:non-scaling-stroke;stroke-width:1px;" id="e1_shape" transform="matrix(8.13356 0 0 8.13356 372.893 316.834)" />
      <path d="M-40.492315,-32.676928l-4,4l4,4l4,-4Z" style="fill:white; stroke:black; vector-effect:non-scaling-stroke;stroke-width:1px;" id="e4_shape" transform="matrix(8.13356 0 0 8.13356 372.893 316.834)" />
      <path d="M-31.138467,-32.800005l-4,4l4,4l4,-4Z" style="fill:white; stroke:black; vector-effect:non-scaling-stroke;stroke-width:1px;" id="e2_shape" transform="matrix(8.13356 0 0 8.13356 372.893 316.834)" />
   </g>
</svg>

Answer №2

Here is the solution that utilizes react-bootstrap and custom CSS for styling

In the render() method of my React Component

const styles = {
    grid: {
        paddingLeft: 0,
        paddingRight: 0,
    },
    row: {
        marginLeft: 3,
        marginRight: 0,
    },
    col: {
        paddingLeft: 0,
        paddingRight: 0,
    },
    center: {
        paddingLeft: 0,
        paddingRight: 0,
    },
};

<Container style={styles.grid}>
    <Row style={styles.row}>
        <Col sm="auto" style={styles.col}>
            <div className="diamond second-base active"></div>
        </Col>
    </Row>
    <Row style={styles.col}>
        <Col sm="auto" style={styles.center}>
            <div className="diamond third-base"></div>
        </Col>
        <Col sm="auto" style={styles.col}>
            <div className="diamond first-base"></div>
        </Col>
    </Row>
</Container>

CSS Classes Used:

div.diamond.second-base {
  border: 13px solid transparent;
  border-bottom: 13px solid #CBCCCE;
  box-sizing: border-box;
  clear: both;
  color: #6C6D6F;
  font-family: inherit;
  ...
}

(Additional CSS classes omitted for brevity)

Solution link: codeSandBox

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

Troubles with implementing child routes in Angular 6

I'm having trouble getting the routing and child routing to work in my simple navigation for an angular 6 app. I've configured everything correctly, but it just doesn't seem to be working. Here is the structure of my app: └───src ...

Grid of images as background using Bootstrap

Currently delving into the world of bootstrap and online tutorials, I have a desire to construct a webpage using solely images as the background. The goal is to create a mosaic-like effect with no borders or space between them. Despite experimenting with ...

I'm having trouble grasping the concept of this asynchronous behavior

After reviewing the output provided, my initial expectation was for working to be displayed between the lines of begin and end. Here is the rule: Is there a possible solution to achieve this outcome without modifying the app.js file? app.js const se ...

What is the best way to horizontally align three animated progress bars alongside images?

Check out this jsfiddle that shows a vertical alignment of the progress bars. How can I modify it to align them horizontally and centered? https://jsfiddle.net/bLe0jLar/ .wrapper { width: 100px; height: 100px; } .wrapper > #bar, #bar2, #bar3 { ...

Having trouble with Bootstrap item rendering correctly on the page

Hey there, I'm currently utilizing bootstrap to create the layout of my webpage. const NewRestaurant = () => { return ( <div className="mb-4"> <form action=""> <div classNam ...

I am incorporating JWT into my Angular 2 application and saving it in localStorage. Yet, what steps should I take if the item is missing?

I have developed a token-service.ts to communicate with my backend authentication API and receive a JWT. The received JWT is stored in the local storage using the getToken() method below: getToken() { this.http.post('myAuthEndpoint', { credent ...

Unable to define a range for the hr element using the nth-of-type selector

Why isn't the hr element from the 1st to the 3rd hour red as specified in the CSS code below? hr:nth-of-type(n+1):nth-of-type(-n+3){ background:red; } <!DOCTYPE html> <html> <head> </head> <body> <hr /> <p>T ...

Tips for implementing lazy loading for a section of a template in Angular 2

I have an Angular 2 component that has several sub-components within it. Some of these sub-components are expensive to load and may not always be necessary, especially if the user doesn't scroll far enough down the page. Although I am familiar with l ...

How to implement a Django block for loading CSS files

I have multiple pages and I need to load unique CSS for each page. I am using this method for all static files. In the head of my index.html file, I have the following code: {% block css %} {% endblock %} However, in my contact.html file, I have the fol ...

AngularJS: Error message stating that '$scope is undefined'

Encountering '$scope is not defined' console errors in this AngularJS controller code: angular.module('articles').controller('ArticlesController', ['$scope', '$routeParams', '$location', 'Au ...

The type 'function that takes in a CustomEvent and returns void' cannot be assigned to a parameter of type 'EventListenerOrEventListenerObject'

When I upgraded from TypeScript version 2.5.3 to 2.6.1, my custom event setup started giving me an error. window.addEventListener('OnRewards', (e: CustomEvent) => { // my code here }) [ts] Argument of type '(e: CustomEvent) => ...

Customize buttons in Material UI using the styled component API provided by MUI

I am intrigued by the Material UI Styled Component API, not to be confused with the styled-component library. However, I am facing difficulty in converting my simple button component into a linked button. Can anyone advise me on how to incorporate a react ...

Tips for aligning two canvases with different heights at the top in HTML5

My problem involves two canvases housed within a single <div>. Despite their different heights, they are currently aligned at the bottom. +-------+ + + +-------+ + + + + + + +-------+ +-------+ Is the ...

I'm curious about the origin of the color on this PrimeNG element. How can I go about changing it?

I'm currently working on a project using Angular 17, incorporating the Clarity and PrimeNG libraries for styling purposes. Within my angular.json file, I have included the following css files: "node_modules/primeng/resources/themes/mdc-dark-indigo/th ...

Vows: proceed to the subsequent error handling process

Can you explain how to properly call the next error function using promise chaining? I initially believed that placing a return statement within the error function would automatically trigger the next error function. //This code is executed in a contr ...

Updating an API parameter in React's setState doesn't reflect the new changes

Having trouble with a web app that I'm currently developing. The issue arises on the recipe page where the search functionality isn't updating as expected. Although it is binded to the Enter key and the request itself works, the state update do ...

Difficulty aligning Material2 icons and title text in CSS styling

I'm encountering a design problem when incorporating material2 icons into my Angular application. Specifically, I have a button that displays both a material2 icon and some text side by side from left to right. Currently, the icons are centered within ...

Having trouble getting the Bootstrap Dropdown to function properly in the Navbar while using NextJs

I am having an issue where the Dropdown menu is not opening up when clicked. I am currently using bootstrap 5 on nextjs 12. I attempted to add the CDN links, but unfortunately, it was not successful. Any assistance or advice would be greatly appreciated. ...

Exploring the features of useEffect and setState in hook functions

Exploring the idea of utilizing React to efficiently fetch data using useEffect correctly. Currently facing a situation where data fetching is occurring constantly instead of just once and updating only when there is an input for the date period (triggeri ...

Tips for troubleshooting getStaticProps (and getStaticPaths) in Next.js

Currently, I am attempting to troubleshoot the getStaticProps() function within a React component that is being utilized from my pages by implementing console.log() like so: export default class Nav extends React.Component { render() { return & ...