Can `display:none` and `display:inline` be used to reveal a hidden element nested within another?

If I want to change the appearance of certain classes with CSS, I can do so in the following code:

  <ul class="productText">
    <li>Thycotic Secret Server <span id="headerControl_VersionNumber" class="VersionNumber">8.8</span></li>
    <li class="EditionLabel"><span id="headerControl_EditionNameLabel" class="EditionName">Express Edition</span>  </li>
  </ul>

I would like to use :before to replace the text Thycotic Secret Server, and also replace Express Edition.

Is it possible for me to hide .productText li{} using display:none, while still keeping .EditionLabel span{} or .EditionName :before visible?

For example:

  .productText:before {
      content:"to replace Thycotic Secret Server" !important;
  }

  .productText li{
      display:none !important;
  }

  .EditionName li{
      display:inline !important;
  }

  .EditionName:before {
      content:"to replace Express Edition" !important;
  }

This method does not work as all sub-elements of .productText that are type li are hidden.

Can I achieve what I want with the given code?

[solution]

Since the text within all li elements has its font-size set to 0, I had to use more specific elements to control the properties.

  .productText li{
    font-size: 0;
  }

  .productText:before {
    font-size: 1rem;
    content:"replaced larger text"
    font-variant:small-caps;
  }

  .EditionName:after {
    font-size: 0.8rem;
    content:"replaced smaller text"
  }

In this particular example, I found the font-size for EditionName in the original CSS and incorporated it into this set to maintain the same appearance.

Answer №1

To customize the size of text, you can experiment with the font-size property.

li { font-size: 0; }
li span { font-size: 1rem; }
li span:before { content:"to substitute for Thycotic Secret Server "; }

Check out this demonstration: http://codepen.io/anon/pen/zxarjd

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

Every time an input field is clicked, an email is sent

I'm struggling with the contact form on my website. Instead of sending an email after clicking on each input field, I want it to send only one email after hitting the submit button. Currently, it sends a total of 5 emails - 1 with user inputs and 4 wi ...

disabling a submit button

I am new to coding and need help disabling a button on document load. Can someone assist me with this? Here is my current code snippet: $(document).ready(function() { setTimeout("check_user()", 250); }); Your guidance is greatly appreciated! ...

Generating an Xpath for the selected element with the help of Javascript or Jquery - here's how!

On my website, I have implemented a click event on an element. When a user clicks on this element, I want to generate the XPath of that particular element starting from either the html or body tag, also known as the Absolute Xpath. For example, if I click ...

Arrange the divs in numerical order based on the number of downloads

I wrote a basic code to organize parent divs based on their titles. However, when I attempted to do the same for download counts, nothing happened - no errors or actions from the code. There are two functions in total, both of which are triggered by butto ...

Datetimepicker initialization with default start date

I need to disable all dates for the specific date stored in a session. My attempt: The session contains the following date format: dd-mm-yyyy $_SESSION['beschikbaar']; This is the input field <input class="form-control" type="text" place ...

Using jQuery to toggle the visibility of select options for multiple elements

Hey there, I've got this code snippet that effectively shows and hides elements based on a selected option. It works well with one element, but when I try to use it with multiple elements, it doesn't function correctly. How can I tweak it so that ...

Retrieve the minimum and maximum values from a multi-dimensional array

If my array consists of the following subarrays: array = [[1, 5, 8, 9], [3, 7], [3, 8, 33], [2], [0, 6]] I am looking to determine the maximum and minimum values in this array. For example, in this case: max = 33, min = 0 While I have come across exampl ...

Manage responses from ajax submission

My settings form has a unique feature to prevent users from making changes by mistake. After completing the form, users click the save button to trigger a modal (using Bootstrap modals) asking for their password before processing the original form. If the ...

Adjust the field's color depending on the outcome displayed within

I'm trying to implement a feature where the field value changes to green when "OK" is selected and red when "NOK" is chosen. I have written the following JavaScript code but it's not working as expected - the colors change before clicking submit, ...

The Follow/Unfollow button fails to function properly when attempting to unfollow by using the same ajax call

A scenario where dynamically generated buttons (anchors) are displayed on a page, each with a unique ID and a common class. With the class, I am able to retrieve the ID using jQuery and send it to the controller for processing. Although I can successfully ...

What is the best way to adjust the underline with Bootstrap?

Is there a way to add an underline to text without using CSS? I've tried using <p><u>text</u></p> and class="text-decoration-underline">, but neither provide an option to adjust the vertical position of the underli ...

What is the process for embedding JQuery within the <body> tags in Joomla 3.1?

I inserted the following code into my default.php file in Joomla 3.1. <?php JHtml::_('jquery.framework'); JFactory::getDocument()->addScript(JURI::root().'template/mytemplate/js/jquery.min.js'); ?> However, this code only pl ...

Obtaining a single element from a hidden display while dragging using Jquery UI

Is there a way to move an element outside of a container with overflow hidden when using drag and drop functionality in CSS? Currently, when I drag an element with the "item" class, it stays within the confines of the container with overflow set to hidden. ...

When trying to load an ASPX file with jQuery UI Tabs, pressing the ASP button results in an error message saying "page not found."

I am a newcomer to the world of jQuery and AJAX, facing an issue with implementing jQuery UI tabs. The problem arises when I load separate .aspx pages into each tab and try to carry out regular processing tasks without reloading the entire page. Currently, ...

Launch Bootstrap 4 Modal using JavaScript with just a simple click on a hyperlink

My goal is to trigger a modal to open when a link is clicked, but unfortunately I am unable to modify the HTML of the link itself. The only thing I can change is the href attribute. For example: <a href="#Modal">Open modal</a> I am not able ...

Designing dynamic SVG elements that maintain uniform stroke widths and rounded edges

I'm currently tackling a project that involves creating SVG shapes with strokes that adjust responsively to the size of their parent container. My aim is for these shapes to consistently fill the width and height of the parent container, and I intend ...

Organize columns on mobile devices using Materialize

I'm currently working with the materialize framework and am attempting to change the order of columns on mobile view. Specifically, I want the BUY BUTTON to appear before the CONTENT section on phones. I've been experimenting with pull and push b ...

Tampermonkey's .click() function appears to be malfunctioning

I am attempting to automate clicking a button in Tampermonkey, but for some reason the code is not working as expected. Interestingly, when I manually run the code in the console, it functions perfectly. Here is the snippet: $(document).ready(function() ...

Using Bootstrap 4 to split lengthy text into multiple columns, similar to how it is done in Microsoft Word

Is there a way in Bootstrap4 to create MS Word-like multicolumn text flow? For example, in Word we have: https://i.sstatic.net/buCXu.png In Bootstrap4, the code below will generate a two-column grid: Example: <div class="row"> <div ...

adjusting state with React hooks

I currently have two buttons labeled create signature and Create delivery in my file PageOne.tsx. When the state is set to InDelivery, both buttons are visible. My goal is to hide the Create delivery button initially. However, when a user clicks on the cr ...