JosafKolluri Posted on Jul 2, 2020 How can we display a half digit as shown as above using HTML and CSS? #html #csstricks I had a doubt about above image. How can we display a half digit as shown as above using HTML and CSS? if anyone know , please help me? Top comments (2) Subscribe Submit Preview Dismiss Collapse Expand Adnan Rizvan Adnan Rizvan Adnan Rizvan Follow I write code.... for money Location Bugojno, Bosnia & Herzegovina Work Senior Developer at Bragg Joined Dec 18, 2019 • Jul 2 '20 • Edited on Jul 2 • Edited Dropdown menu Copy link Hide You can use the before pseudo-element to achieve this. For example: CSS section { position: relative; overflow: hidden; display: block; height: 300px; width: 100%; background: red; &::before { content: '02'; position: absolute; top: -25px; left: -15px; color: yellow; font-size: 60px; } } HTML <section>...</section> Edit: In order to make the number dynamic, you can set a data attribute on the section like data-section-id and in css use content: attr(data-section-id) Collapse Expand JosafKolluri JosafKolluri JosafKolluri Follow Location Hyderabad Work UI Developer Joined Jun 28, 2020 • Jul 2 '20 Dropdown menu Copy link Hide Please help me to solve above problem Code of Conduct • Report abuse
Top comments (2)
You can use the before pseudo-element to achieve this. For example:
CSS
HTML
Edit: In order to make the number dynamic, you can set a data attribute on the section like
data-section-idand in css usecontent: attr(data-section-id)Please help me to solve above problem