"Want to add a dynamic touch to your table cell? Learn how to create a

My design file looks like this:

https://i.sstatic.net/OfM6A.jpg

I'm trying to create a triangle shape in a table cell only for the active sort using CSS.

However, when I attempt to implement it based on this demo:

https://i.sstatic.net/djIHy.jpg

I would like the triangle to be centered underneath the table header instead.

.table-bordered th {
    background-color: #24374a;
    border: 0;
    color: #ffffff;
    cursor: pointer;
}

.table-bordered th.active {
    background-color: #041323;
    position: relative;
}

.table-bordered th.active:after {
    content: "";
    position: absolute;
    top: 0;
    right: 0;
    width: 0;
    height: 0;
    display: block;
    border-left: 20px solid transparent;
    border-bottom: 20px solid transparent;
    border-top: 20px solid #f27e0a;
    margin: auto;
}
<table class="table table-bordered" id="domainTable">
    <thead>
    <tr>
        <th class="active" onclick="sortTable(0)">Commercial Domains</th>
        <th onclick="sortTable(1)">Affordable Domains</th>
        <th onclick="sortTable(2)">National Domains</th>
        <th onclick="sortTable(3)">Service Domains</th>
        <th onclick="sortTable(4)">Country Domains</th>
    </tr>
    </thead>
    <tbody>
    <tr>
        <td></td>
        <td></td>
        <td></td>
        <td></td>
        <td></td>
    </tr>
    </tbody>
</table>

Answer №1

Your desired outcome.

.table-bordered th {
    background-color: #24374a;
    border: 0;
    color: #ffffff;
    cursor: pointer;
    
    height: 100px;
    width: 150px;
}

.table-bordered th.active {
    background-color: #041323;
    position: relative;
}

.table-bordered th.active:after {
    content: "";
    position: absolute;
    top: 55%;
    left: 0;
    right: 0;
    transform: rotate(45deg);
    height: 20px;
    width: 20px;
    border-bottom: 5px solid #f27e0a;
    border-right: 5px solid #f27e0a;
    margin-left: auto;
    margin-right: auto;
    
}
<table class="table table-bordered" id="domainTable">
    <thead>
    <tr>
        <th class="active" onclick="sortTable(0)">Commercial Domains</th>
        <th onclick="sortTable(1)">Budget-friendly Domains</th>
        <th onclick="sortTable(2)">National Domains</th>
        <th onclick="sortTable(3)">Service Domains</th>
        <th onclick="sortTable(4)">Country Domains</th>
    </tr>
    </thead>
    <tbody>
    <tr>
        <td></td>
        <td></td>
        <td></td>
        <td></td>
        <td></td>
    </tr>
    </tbody>
</table>

Answer №2

.triangle {
  position: absolute;
  top: 80%;
  right: 50%;
  float: right;
  width: 0;
  height: 0;
  border-right: 10px solid transparent;
  border-bottom: 10px solid red;
  transform: rotate(-45deg);
}

td {
  border: solid 3px black;
  width: 160px;
  height: 100px;
  position: relative;
}
 <table class="table">
      <tbody>
        <tr>
          <td>
            <div class="triangle"></div>Make necessary adjustments
          </td>
        </tr>
      </tbody>
    </table>

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

data-cy appears in the DOM structure, yet remains unseen

I'm seeking some clarity on how to effectively use Cypress. While writing end-to-end tests, I encountered a failed test due to the element not being visible. A helpful answer I found assisted me in resolving this issue by clicking an element that was ...

Is there an issue with JQM plugin due to jQuery's append() function?

I am just starting to learn about jQuery mobile as I develop an app using it. Whenever I click on the Add_details button, I want to add dynamic input fields only once. After saving, if I click on the Add_details button again, I need to append more dynamic ...

The appearance of the logout button may differ depending on the web browser being used

I have implemented a straightforward logout button using the following code: <li><a href="http://localhost:8666/web1/profile/mainpage/logout.php" onclick="return confirm('Are you sure to logout?');">Log Out</a>&l ...

The Bootstrap validation does not display the appropriate checkmarks

I am using Bootstrap validation and I do not want the green checkmark to be displayed when the inputs are correct. I searched the Bootstrap documentation but could not find a way to hide the green checkmarks. <script> // Here is an example of Java ...

Mobile device causing elements to resize unevenly

On my simple webpage, I have a combination of text and a table. Check out the HTML below: <body> <div id='stat'> <p class='subheading'>Stat of the Week: Average Final Standings</p> <p class='text&apo ...

Flask Pagination : UnboundLocalError occurs when trying to reference a local variable 'res' before it has been assigned

I'm currently troubleshooting an issue with flask pagination. Whenever I attempt to implement it, I encounter the UnboundLocalError. Even after removing all variables, the pagination feature still fails to function as intended. @app.route('/&apos ...

Contrasts between space and the greater than selector

Can you explain the distinction between selector 6 and selector 7 as outlined on the w3 website? Inquiring minds want to know. ...

Using AngularJS to iterate over a collection containing various types of data elements, but specifically filtering for dates

I'm currently using ng-repeat to iterate over a collection containing fields with various data types. I specifically want to format only the date fields using something like {{mydate | date}}, but I'm unsure how to apply this only to the date fie ...

AngularJS telephone input

In my opinion, AngularJS does not properly respond to input[type=tel]. There is a lack of online documentation regarding this issue. I have tried using ng-model, ng-value, and value but none of them seem to work. -- Has anyone figured out how to input ...

Tips for positioning the popup ul in relation to its parent li

How can the pop-up ul be positioned in the center of the parent li using CSS? * { margin: 0; padding: 0; } #track-nav { margin-left: 50px; margin-top: 50px; float: left; width: 100%; list-style: none; font-weight: bold; margin-bottom: ...

Organizing communications in NodeJS messaging application

My latest project involves creating a chat room using NodeJS and socket.io which allows multiple users to connect with unique usernames. Everything is running smoothly, except for one minor issue. I want the messages sent by me to appear in a different co ...

The CSS transition fails to function properly within an accordion when the submenu is set to 100% width

I have designed a simple accordion menu using jQuery and CSS transition to display submenus. Here is an example: HTML: <div class="container"> <ul class="nk-menu list-unstyled" id="side-menu"> <li class=& ...

Incorporating Bootstrap 4 into Slate V1 - Exploring Dual Indexes using Chrome Developer Tools

As a beginner in web development, I have dabbled in some areas before but never really delved into website creation. I do have a basic understanding of CSS, Javascript, and HTML though. I recently installed Slate theme and integrated Bootstrap 4 files int ...

Struggling with integrating a mixin in your Polymer project?

I'm experiencing difficulties trying to implement a mixin in Polymer. I have created --test-theme, but it seems that the style is not being applied inside the element. Any suggestions on where I might be making a mistake? story-card.html <dom-mod ...

Adding hash history to a sortable showcase: A step-by-step guide

I am in the process of developing a filterable portfolio feature for my website. Once a user clicks on a filter, it adds a hashtag to the end of the URL. For example, clicking on 'design' would result in www.yourdomain.com/#design. I am wonderin ...

Following the recent update of Google Chrome, Sencha Touch experiences spinning issues

Since updating my Google Chrome to the latest version (v29.0.1547.57 m), I've noticed some issues with parts of my Sencha Touch app spinning. The Sencha Touch version I am using is v2.2.1. For example, when using Ext.Msg.alert, I can see the title bu ...

Pictures displayed in a bootstrap carousel are not completely filling up the entire carousel space

I recently started working with Ruby and decided to use the refile Gem for uploading multiple photos. I wanted to showcase the photos in a Carousel format using Bootstrap carousel. However, when I display the photos, they don't fill the carousel windo ...

What is the best way to establish a maximum limit for a counter within an onclick event?

I'm struggling to figure out how to set a maximum limit for a counter in my onclick event. Can someone help me? What is the best way to add a max limit to the counter of an onclick event? Do I need to use an if statement? If yes, how should it be w ...

Highlighting in ThreeJS/Projector Interface

Is there a way to incorporate a 2D sprite underneath a 3D object on top of a plane in order to indicate that my objects are highlighted or selected? Additionally, how can this be achieved on uneven terrain? To provide further clarification, I have includ ...

Support for the percent sign in right-to-left languages

Imagine you have the following code snippet: <div dir="rtl"> test 50% </div> It currently displays as test 50%. However, according to this wiki page, for Arabic language it should be shown as %50 test, with the percentage sign before the n ...