• Resolved Jim

    (@jwmc)


    This is a minor thing, but driving me nuts. I finally figured out how to implement TSF breadcrumbs so I can drop a breadcrumb plugin. To me the space around the separator looks too large. It is implemented by TSF with inline code I’m not familiar with, in style tags after the actual elements:

    <style>nav.tsf-breadcrumb ol{display:inline;list-style:none;margin-inline-start:0}nav.tsf-breadcrumb ol li{display:inline}nav.tsf-breadcrumb ol li:not(:last-child)::after{content:'?';margin-inline-end:1ch;margin-inline-start:1ch}</style>

    I’m trying to override it in a stylesheet as follows, but it doesn’t work. Maybe all that stuff in the selector after li messes it up?

    nav.tsf-breadcrumb ol li:not(:last-child)::after {
      margin-inline-start: 0.5ch !important;
      margin-inline-end: 0.5ch !important;
    }

    The page I need help with: [log in to see the link]

Viewing 2 replies - 1 through 2 (of 2 total)
  • Plugin Author Sybre Waaijer

    (@cybr)

    Hello!

    In TSF 5.0.2, we increased the specificity of the CSS to resolve a widespread issue. This, in turn, requires theme developers to be even more specific, such as annotating the wrapper block such as .site-header, or even the entire body (but that is not recommended):

    .site-header nav.tsf-breadcrumb ol li:not(:last-child)::after {
      margin-inline-start: 0.5ch;
      margin-inline-end: 0.5ch;
    }

    Alternatively, you can use a PHP filter. To mitigate a crash if the selector disappears or changes, we forgo using array_push() and write directly to the variable instead.

    To prevent repeating the selector, I created a pointer. This pointer causes anything we write to the $sep_css pointer variable to be written to the primary $css variable’s separator index.

    add_filter(
    	'the_seo_framework_breadcrumb_shortcode_css',
    	function ( $css, $class ) {
    
    		// Create a pointer so we do not have to write the long selector repeatedly.
    		$sep_css = &$css[ "nav.$class ol li:not(:last-child)::after" ];
    
    		$sep_css[] = 'margin-inline-end:.5ch';
    		$sep_css[] = 'margin-inline-start:.5ch';
    
    		return $css;
    	},
    	10,
    	2,
    );

    I hope this helps! Have a lovely day ??

    Thread Starter Jim

    (@jwmc)

    Thank you, Sybre. I don’t quite get the PHP filter, but luckily your CSS solution worked. Actually, mine did too, after I fixed an editing error in the stylesheet ?? I appreciate the help.

Viewing 2 replies - 1 through 2 (of 2 total)
  • The topic ‘Format space around separator in breadcrumb’ is closed to new replies.