Having trouble with the Details/Summary marker design in Safari/Webkit

Currently, I am trying to position the flippy triangle to the right of the <summary> element when using the <details> tag.

Instead of the default alignment like this:

▶ My Cool List (aligned to the left)

I would like it to be like this:

My Cool list ▶ (aligned to the right)

Here is how it appears in Chrome:

https://i.sstatic.net/3IhmF.png

This post was helpful in writing the CSS that works on both Chrome and Firefox:

// Align all summaries to the right.
details > summary {
  list-style: none; // Remove the default arrow.
  display: flex;
  align-items: center; // Vertically center the arrow.
}
details > summary::-webkit-details-marker {
  display: none;
}
details > summary::after {
  content:  '▶';
}
details[open] > summary::after {
  content: "▼";
}

However, Safari displays the flippy triangle on a new line when tested on Mojave desktop, iOS14, and iOS12:

My Cool List
▶ 

View the issue in Safari here:

https://i.sstatic.net/QgOEd.png

So, my question is, how can I make Safari show the flippy triangle on the same line as Firefox and Chrome? It seems like the problem arises from the combination of using display: flex with the ::after pseudo-element, but as someone unfamiliar with frontend development, I am unsure how to resolve this.

Answer №1

Interestingly, Safari seems to have trouble with <p> elements within a <summary>; after removing them, I found that flex wasn't even necessary to align the pseudoelement to the right.

Answer №2

If you encounter the display: flex; issue with the <summary> element, you can apply browser-specific CSS to solve it.

To address this in regular CSS

@media not all and (min-resolution:.001dpcm) { @media {

    details > summary { 

        display: block; 

    }
}}

For SCSS stylesheets

    @media not all and (min-resolution:.001dpcm)
    { @supports (-webkit-appearance:none) {

    details > summary { 

        display: block; 

    }
}}

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

Evenly distribute top and bottom padding within a fixed-height border using CSS

I'm facing a challenge with centering the content vertically on an online certificate that users can print out. The main issue lies in aligning the inner wrapper (#wrapper) inside the outer border (#outerBorder), which has a fixed height to ensure pro ...

Shade your elements with the magic of CSS3

Can someone help me create an object with a drop shadow using CSS3? Here is my current code: <!DOCTYPE html> <html> <head> <style type="text/css"> div { width:300px; height:100px; background-color:yellow; } </style> </ ...

Designing websites using elements that float to the right in a responsive manner

Responsive design often uses percentage width and absolute positioning to adjust to different screen sizes on various devices. What if we explore the use of the float right CSS style, which is not as commonly used but offers high cross-browser compatibilit ...

What is the difference in performance between using element.class { ... } compared to just .class { ... } in CSS?

Is there any impact on performance when specifying div.class or p.class instead of just .class if a certain class will only be used on divs or paragraphs? ...

The Enchanted URL Folder Name

Spent two painstaking hours dealing with this issue. It's incredibly frustrating. Struggling to load css files in PHP pages when the URL contains a folder named "adsq" Comparing two identical pages, only differing in the folder name: One works perf ...

I'm currently working on setting up a gallery on the lower part of my webpage, but for some reason, the lightbox2 images are not aligning next to each other in rows. Can anyone

Struggling to align images in a gallery at the bottom of my webpage. They keep appearing on separate lines instead of next to each other. HTML: <section id="galleries"> <h2>Galleries</h2> <article class="img- ...

Troubleshooting Problem with CSS Gradient Text

I'm attempting to recreate the text effect found here: . However, I'm facing issues getting it to work despite using the same code. This is the HTML I am using: <h1><span></span>Sign Up</h1> My CSS looks like this: h1 { ...

The background image will not repeat to completely cover the height

Click here to view my issue. I have set the background image to repeat the entire height, but it's not behaving as expected. Here is my CSS #wrapper { margin: 0px; padding: 0px; background: url(img02.jpg) repeat-x left top; } I attempt ...

Tips on inserting space in materialize css?

After reviewing the documents, I couldn't find any answers to my questions. Is there a way to create some space between the buttons? Currently, they are positioned right next to each other. Thank you! import React from "react"; import { connect } fro ...

What is the best way to alter the color of the "checkmark" in an HTML checkbox using CSS?

Is it possible to change the color of the check mark in an HTML checkbox? Currently, on Windows XP using Firefox, Chrome, or IE, the check mark appears green. I am interested in changing the check mark within an INPUT type="checkbox" to be orange. ...

What is the best way to connect individual buttons to a dynamic div that displays different content depending on the button clicked?

Hey there! I'm diving into the world of JavaScript and HTML, and I need some guidance on creating a menu that can toggle visibility of specific content in div(s) depending on which button (picture1-12) is clicked. My idea is to have one div that can d ...

Utilizing two distinct CSS frameworks within a single Rails application

At the moment, I have an application with its frontend built using Bootstrap 3 (leveraging the bootstrap-rails gem). Now, I am looking to incorporate the Materialize.css framework into the same app. After downloading the Materialize.css stylesheet, my conc ...

Tips for centering content vertically within a div with specific dimensions?

Is there an optimal technique to center content vertically within a defined width/height div? In this illustration, two contents with varying heights are present. What would be the most effective way to vertically center both using the .content class? (En ...

Use jQuery to apply a class to the body element whenever it contains content

When the body loads the text 'added to your shopping cart.', jQuery needs to add a class to the div with the ID #header-cart. <span> added to your shopping cart.</span> The class should be added and then removed after 5 seconds. ...

Banner advertisement on a webpage

Currently, I am working on a website project for clients who are interested in having background ads displayed throughout the entire site. In terms of coding this feature with CSS, it is relatively straightforward: body { background-image: url('a ...

Ensure that the TextBox field extends to the edges of the parent div, with full cross-browser compatibility

In the following code snippet, there is a challenge in ensuring that the TextBox field properly fits within the Width and Height of the div#chat-message. This seems to work well in Chrome but encounters issues in IE8 or Mozilla. Additionally, in Mozilla, t ...

Dragging a hyperlink onto the web browser using jQuery's drag functionality

Seeking a solution for my small script that allows users to drag a link and also drop it onto the browser bar for bookmarking or sharing. How can I achieve this functionality? Check out an example of one of the drag functions I currently utilize: http:/ ...

Is it possible to customize the appearance of the <audio> tag when used with a playlist?

I am struggling to style an audio tag with a playlist of songs. Does anyone have any pre-made styles that I can use for a normal white MP3 player similar to the one in the picture I attached? The MP3 player I'm aiming for Current player design Her ...

Struggling to align a div in Bootstrap 4/Angular?

I am currently enhancing the appearance of my application using Bootstrap, My current goal is to center a "card" provided by Bootstrap. I discovered that I can achieve this with mx-auto. The code I implemented with mx-auto works perfectly in JSFiddle. ...

Effortlessly implement CSS styling in a scoped shadow element with Vue3

I am facing an issue with applying styles to an anchor element in my code. Below is a snippet of the code: <template> <custom-button> #shadow-root (open) <a href="#"></a> <other-custom></other-c ...