Arranging shapes of traffic lights in a stack

I'm attempting a straightforward task. My goal is to design a basic traffic light using a rectangle and three circles nested within it. Despite my efforts using SVG for the shapes, I've been unable to properly align the circles on top of the rectangle. The end result doesn't need to be interactive. Any guidance would be greatly valued!

Answer №1

I created a simple design using only HTML and CSS. Check out the Stack Snippet below or visit the jsFiddle link for a live demo.

.container{ background: none repeat scroll 0 0 #000;
    height: 100px;
    padding: 10px;
    width: 30px;}
.red, .yellow, .green{border-radius: 100%;
    height: 25px;
    margin-top: 3px;
    padding: 2px;
    width: 25px;}
.red{background: red;}
.yellow{background: yellow;}
.green{background: green;}
<div class="container">
    <div class="red"></div>
    <div class="yellow"></div>
    <div class="green"></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

The error message "Your session has expired" is displayed by the Wysiwyg

The WysiwygPro editor displays a dialog error message stating, "Your editing session has expired. This is usually caused by a long period of inactivity. Please re-load the page," when clicking on any controls such as Image, Media, Emoticon, etc. This iss ...

Tips for invoking a function using ng-model together with the ng-model value

Within a div element, I have a text field where I am using ng-model to capture the value. I need to trigger a function for validation when a date is entered in the text field. How can I achieve this while still utilizing ng-model? Any suggestions on how to ...

Ways to alter the color of individual pseudo elements using a CSS loop

While working on creating a typewriter animation effect for my website using only CSS that I discovered through some online research, a question popped into my mind - is it possible to set different colors for each text in the animation? I have included t ...

`Creating a functional list.js filter``

I'm having trouble making the List.js filter function work properly. The documentation for List.js is not very helpful for someone new to development. Below is the code I am using: HTML: <div class="col-sm-12" id="lessons"> <input class= ...

Extra brackets appear when retrieving JSON data

In my code, I am attempting to extract data from a JSON file. The JSON data does not have any brackets, just an array separated by commas. However, when I retrieve the data using $scope, an extra square bracket is added outside of my output. Here is a demo ...

Is the background image on my class website too large?

I am having an issue with the redbar.png image in my CSS. It is positioned too high (within #container) and overlapping with the horizontal nav bar when it shouldn't be. I'm uncertain how to fix this problem. Any suggestions would be greatly appr ...

What is the sequence in which jQuery events are triggered?

In my HTML code, I have the following: <a href="#" class="topHierarchy big-link" data-reveal-id="myModal" > Both classes, "topHierarchy" and "big-link", are used to attach jQuery event handlers (onClick). big-link triggers a popup box to show, whi ...

Top and bottom fieldset legends in Bootstrap 4

Looking for suggestions on how to include legend text on the bottom border in bootstrap 4. I attempted to use position and margin, but it didn't work. <link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/4.0.0/css/bootstrap.mi ...

Utilize AngularJS to bind a variable and display an external HTML file without the need to open it in a browser

In my setup, I have two HTML Views - one is for application purposes and the other is for printing. Let's call them Application.html and PrintForm.html, respectively. Here is a snippet from Application.html: <!DOCTYPE html> <html> < ...

What could be the reason for the checkbox being toggled twice?

Here is the code snippet I am working with: $("input[type='checkbox']").each(function() { var current = $(this); $("label[for='" + current.attr("id") + "']").on('click', function() { current.change(); al ...

Tips on keeping a Material UI menu item open when clicked

My menu consists of a single item, which is a text field along with a button. The idea is to input some information, save it by clicking the button, and then close the menu either by hitting "close" or the original button again. How can I stop the MenuItem ...

Preventing Flash of Unstyled Content in ElectronJS Browser Windows

Upon creating a new BrowserWindow and utilizing loadURL to incorporate an html file within the renderer, there is a brief instance where unstyled content is displayed for approximately half a second before the css is loaded. window.loadURL('file://&a ...

What is the best way to align an Icon in the navbar-toggler of Bootstrap 5?

When working with Angular and Bootstrap to develop a navigation bar, I encountered an issue with aligning a user icon in the navbar. The picture below shows the problem that arises when trying to center align the user icon among other links in the navbar. ...

What is the most effective method for coding an input tag with specific restricted characters?

Introduction I have a unique idea for creating an input field of fixed length where users can fill in the gaps without modifying certain pre-filled characters. For example, I want to display "__llo w_rld!" and let users complete the missing characters. In ...

How to modify the color of a div element with jQuery?

I need some help changing the color of a div with 'jQuery', but I am not sure how to do it. Below is the code I have been trying: function updateDivColor() { $('#OutlineX1').css("color","blue"); } ...

Guide on how to modify the color of a single row within a table with just a click

My table structure is as follows: <table> <tr> <td>A1</td> <td>A2</td> <td>A3</td> <td>A4</td> </tr> <tr> ...

Conceal a specific element (such as a button) using the visibility property

Trying to hide a button without affecting the spacing between buttons. $(document).ready(function(){ $('#hide').click(function(){$('#btn').css('display','none');}); $('#show').click(function(){$(&a ...

establish a distinct row color pattern for the initial column

I am currently working on a table that has sticky columns. I am trying to create alternating row colors in the first column only. Below is the code for the table: <div class="table-responsive"> <table class="table table-bordered table-stripe ...

Reserved space for both double and single quotation marks

I've created a function that generates a table of specified size with predetermined content in each cell, and displays it within a designated div ID. generate_table(4, 4, 'Cell Content', 'display') To test this function, I added a ...

What could be causing the issue with HTML not being printed upon button click in ReactJS?

My goal is to display the word "Hello" on the screen when the add button is clicked. However, I am encountering an issue where it is not showing up. Any insights or solutions would be greatly appreciated! import React, { Component } from 'react'; ...