• Guest, before posting your code please take these rules into consideration:
    • It is required to use our BBCode feature to display your code. While within the editor click < / > or >_ and place your code within the BB Code prompt. This helps others with finding a solution by making it easier to read and easier to copy.
    • You can also use markdown to share your code. When using markdown your code will be automatically converted to BBCode. For help with markdown check out the markdown guide.
    • Don't share a wall of code. All we want is the problem area, the code related to your issue.


    To learn more about how to use our BBCode feature, please click here.

    Thank you, Code Forum.

CSS Add an Horizontal line in <summary>

SpongeBOB

Well-Known Coder
Hi,

I would like to have a <details>\<summary> that got an horizontal line across the page.. like this

---------- ► To expand ----------

---------- ▼ Expended ----------
blabla
blabla

I've tried the following

HTML:
    <details open>
        <summary>Summary</summary>
        Blablabla
    </details>

CSS:
summary {
  text-align: center; 
  font-size: 1em;
  cursor: pointer;
}
hr {     
    overflow: visible;
    text-align: center;   
    width: 90%;
    height: 0px;
    border: solid black 1px;
}
hr:after {
    background: white;
    content: 'Super test';
    padding: 0 7px;
    position: relative;
   top: -11px   
}

/* test */

summary[open] > hr:before {
  content: 'test'
}

Result ->
result.png

So of course the :marker is not aligned with the rest, that why I tried summary[open] but it's not working (without [open] it does..)

Any ideas ??
 
Solution
I've found ! ( I'll post the solution later on :) )


CSS:
summary::marker{
    content: ''
}

hr{   
  display: inline-block;
}

details span:before {
    content: '►';
}

details[open] .SummSpan:before {
    content: '▼';
}
span{
display: inline-block;
}


HTML:
<summary>
    <hr>
        <span>Your Title section</span>
    <hr>
</summary>

To adapt to your need but this the idea :)
I've found ! ( I'll post the solution later on :) )


CSS:
summary::marker{
    content: ''
}

hr{   
  display: inline-block;
}

details span:before {
    content: '►';
}

details[open] .SummSpan:before {
    content: '▼';
}
span{
display: inline-block;
}


HTML:
<summary>
    <hr>
        <span>Your Title section</span>
    <hr>
</summary>

To adapt to your need but this the idea :)
 
Last edited:
Solution

New Threads

Buy us a coffee!

300x250
Top Bottom