Text spans

by Digvijay Naruka

HTML

This text is<span class="hierarchy-separator">,</span> <span class="hidden-preview">hidden </span> and<span class="excluded-search">
         excluded
    </span>

CSS

.hidden-preview, .excluded-search    ,.hierarchy-separator {
            position: relative;
            opacity: 0.5;
            color: gray;
            font-style: italic;
        }
          .hidden-preview:hover, .excluded-search:hover    ,.hierarchy-separator:hover {
            opacity: 1;
            color: black;
        }
        .hidden-preview {
            border: 2px dashed red;
            background-color: rgba(255, 0, 0, 0.1);
        }
        .excluded-search {
            border: 2px dashed blue;
            background-color: rgba(0, 0, 255, 0.1);
        }
        .hidden-preview::before {
            content: 'Hidden';
            position: absolute;
             top: 100%;
            right: 0;
            background-color: red;
            color: white;
            padding: 2px 5px;
            font-size: 10px;
        }
        .excluded-search::before {
            content: 'Not Searchable';
            position: absolute;
            top: 100%;
            background-color: blue;
            color: white;
            padding: 2px 5px;
            font-size: 10px;
        }
        
        .hierarchy-separator {
             color: green ;
            font-weight: bold;
            position: relative;
            display: inline-block;
            padding-bottom: 10px;
        }
      .hierarchy-separator::before {
            content: 'Separator';
            position: absolute;
           top: 80%;
            left: -20px;
            background-color: green;
            color: white;
            padding: 2px 5px;
            font-size: 10px;
        }
           .hierarchy-separator::after {
            content: 'â–˛';
            position: absolute;
            top: 50%;
            left: 50%;
            transform: translateX(-50%);
            white-space: nowrap;
            text-align: center;
            font-size: 12px;
            color: green;
            line-height: 1.2;
        }

JavaScript

function toggleStyles() {
            var element = document.querySelector('.hidden-preview.excluded-search');
            element.classList.toggle('hidden-preview');
            element.classList.toggle('excluded-search');
        }