Creating one (only one) TAB

Hi again guys. I wanted to create one — only one — tab on a project I anonymized pursuant to Sitepoint’s policy. The tricky part about this is that I want the one tab to curve out at the bottom-left and bottom-right positions — like you would see on a typical manilla file folder.

My intention then is to continue this “flow” into straight lines — of, say, 20px in height — a respectable 200px on either side — a cutaway, in other words. All the tutorials on this presume you’ll have multiple tabs but I only want the ONE, black, centered, with a couple hundred pixels on either side forming the cutaway (also in black).

Think of it as though you held a center-tabbed manilla file folder in your hand and cut 2” to the left of the flow and 2” to the right. Hope that helps.

i created four empty classes in the CSS for your use (labeled flow1, flow2 etc.) in creating the flow — which is, again, the curve going OUT the base of the tab. As you can see I created the border-radius on the top of the tab already (thank you PAUL).

Or do you think I should just use an image of a tab and not attempt something this ambitious? Thanks guys!

Edit if someone could get me the way that you post code HERE I could clean this up so it’s presentable. Otherwise I have to use Codepen which I frankly would prefer not to use!

semicodin

<!DOCTYPE html>
<HTML LANG="en">
<HEAD>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1">

<link rel="preconnect" href="https://fonts.googleapis.com"> 
<link rel="preconnect" href="https://fonts.gstatic.com" crossorigin>
<link href="https://fonts.googleapis.com/css2?family=Courier+Prime:ital,wght@0,400;0,700;1,400;1,700&display=swap" rel="stylesheet">
<link href="https://fonts.googleapis.com/css2?family=Roboto+Slab:wght@100;200;300;400;500;600;700;800;900&display=swap" rel="stylesheet">
<link href="https://fonts.googleapis.com/css2?family=Roboto+Condensed:ital,wght@0,400;0,700;1,400;1,700&display=swap" rel="stylesheet">
<link href="https://fonts.googleapis.com/css2?family=Calistoga&display=swap" rel="stylesheet">
<link href="https://fonts.googleapis.com/css2?family=Special+Elite&display=swap" rel="stylesheet">

<title>99_PUBLIC FILE TAB &#7172; ONE TAB ONLY!</title>

<style>

body {
    width: 950px;
    margin-right: 0rem;
    margin-top: 2rem;
    margin-bottom: 3.75rem;
    font-family: 'courier prime', monospace;
    font-size: 2.25rem;
    line-height: 2.38rem;
    font-weight: bold;
    color: black;
}
.ctr {text-align: center}

.title {
	text-align: center;
    margin-top: 1.25rem;
    margin-bottom: 1.25rem;
    font-family: 'special elite', serif;
    font-weight: 400;
    font-size: 2.25rem;
    line-height: 2.5rem;
}
.flow1 {


}
.flow2 {


}
.flow3 {


}
.flow4 {


}
.hilitea {
    text-align: center;
    border-radius: 20px 20px 0px 0px;
    color: white;
    background-color: #000000;
    padding-top: .5rem;
    font-family: 'courier prime', monospace;
    font-size: 2.5rem;
    line-height: 2.63rem;
    font-weight: bold;
}
.tally {
    font-family: 'calistoga', serif;
    font-weight: 700;
	font-size: 2.25rem;
    line-height: 2.38rem;
    color: crimson;
}
.notes {
	text-align: justify;
	color: black;
    margin: 2rem 2.5rem 1.25rem 2.5rem;
    font-family: 'roboto condensed', sans-serif;
    font-size: 2.25rem;
    line-height: 2.38rem;
    font-weight: 400;
}

.table1 {
    width: 100%;
    text-align: left;
    vertical-align: middle;
    border-top: .63rem groove #00ffff;   /* cyan */
    border-right: .63rem groove #00ffff;
    border-bottom: none;
    border-left: .63rem groove #00ffff;
    border-collapse: collapse;
    font-family: 'courier prime', monospace;
    font-size: 2.25rem;
    line-height: 2.38rem;
    font-weight: bold;
    color: black;
}
td {
    padding-top: .6rem;
    padding-right: .6rem;
    padding-bottom: .2rem;
    padding-left: .7rem;
}

.table1 tbody tr:nth-child( odd ) {
    background-color: #ffffcc;        /* pastel yellow */
    border-bottom: .19rem solid black;
}
.table1 tbody tr:nth-child( even ) {
    background-color: white;
    border-bottom: .19rem solid black;
}

/* FILLING OUT THE CELL BORDERS */

.table1 tbody tr td:nth-of-type(1) {
    border-right: .19rem solid black;
    text-align: left;
}

.table1 tbody tr td:nth-of-type(2) {
    border-right: .19rem solid black;
    text-align: left;
}

.table2 {
    width: 100%;
    border: .63rem groove #00ffff;    /* cyan */
    border-collapse: collapse;
    font-family: 'courier prime', monospace;
    font-size: 2.25rem;
    line-height: 2.38rem;
    font-weight: bold;
    color: black;
}

/* DEFINING THE HEADER */

.table2 th {
	border: .38rem solid #00ffff;
    background-color: black;
    font-family: 'roboto slab', serif;
    font-size: 2rem;
    line-height: 2.13rem;
    color: white;
    font-weight: bold;
    padding: .94rem;
}

/* APPLYING THE STRIPES */

.table2 tbody tr:nth-child( odd ) {
    background-color: #ffffcc;        /* pastel yellow */
    border-bottom: .19rem solid black;
}
.table2 tbody tr:nth-child( even ) {
    background-color: white;
    border-bottom: .19rem solid black;
}

/* FILLING OUT THE CELL BORDERS */

.table2 tbody tr td:nth-of-type(1) {
    border-right: .19rem solid black;
    text-align: center;
}
.table2 tbody tr td:nth-of-type(2) {
    border-right: .19rem solid black;
    text-align: left;
}
</style>
</head>

<body>
    <div class="title">
        To-morrow, and to-morrow, and to-morrow,
    </div>
    <div class="ctr"><span class="hilitea">&mdash;Creeps&mdash;</span></div>

<table class="table1">
        <tr>
            <td colspan="3" style="background: #dddddd">
<span class="tally">in this</span> petty pace<br>
<span class="tally">from</span> day to day
            </td>
        </tr>
    </table>

<table class="table2">
        <thead>
<tr>
                <th style="color: #00ffff; text-align: center; border-collapse: collapse;">
                    to
                </th>
               <th style="color: #00ffff; text-align: center; border-collapse: collapse;">
                    the last syllable of recorded
                </th>
<th width="100px" style="color: #fffff5; text-align: center;">
                    time</th>
            </tr>
        </thead>
        <tbody>

<tr>
                <td>And</td>
                <td>all our <i>yesterdays have lighted</i></td>
                <td class="cell1">fools</td>
            </tr>
<tr>
                <td>the</td>
                <td><span class="blu">way to</span><br>
dusty death.
                </td>
                <td>Out! Out!<br>
                        brief<br>
                        candle
                </td>
            </tr>
</table>

<div class="notes">
        Life&rsquo;s but a walking shadow,
        <br>
        <br>
        a poor player that struts and frets his hour upon the stage
        <br>
        <br>
        and then is heard no more.
        <br>
        <br>
</div>

</body>
</html>

I’m not back to the desktop until later but I do have an old codepen of tabs that show how to round the inverse corners

Just select one of the inner tabs to see if that’s the effect you mentioned.

I wouldn’t use images for this as that’s too rigid and would break on text sizing.

I’ll be back later to look at your actual example.

Roughly like this.

.tab{
  max-width:500px;
  margin:auto;
  padding-bottom:10px;
  position:relative;
}
.tab:after{
  content:"";
  position:absolute;
  left:0;
  right:0;
  bottom:0;
  border-top:10px solid #000;
  border-radius:10px 10px 0 0;
}
.hilitea {
    display:table;
    position:relative;
    margin:auto;
    text-align: center;
    border-radius: 20px 20px 0px 0px;
    color: white;
    background-color: #000000;
    padding-top: .5rem;
    font-family: 'courier prime', monospace;
    font-size: 2.5rem;
    line-height: 2.63rem;
    font-weight: bold;
}
.hilitea:after,
.hilitea:before {
  content: "";
  position: absolute;
  z-index: 2;
  top: 1rem;
  bottom: 0;
  width: 18px;
  box-shadow: 0 10px #000; /* this is necessary or a gap will show */
}
.hilitea:after {
  right: -17px;
}
.hilitea:before {
  left: -17px;
}
.hilitea:after {
  border-radius: 0 0 0 10px;
}
.hilitea:before {
  border-radius: 0 0 10px 0;
}

The html would be this:

<div class="tab"><span class="hilitea">&mdash;Creeps&mdash;</span></div>

It would go in here:

 <div class="title">
    To-morrow, and to-morrow, and to-morrow,
  </div>
  
  <div class="tab"><span class="hilitea">&mdash;Creeps&mdash;</span></div>

  <table class="table1">
    <tr> 
    etc...
1 Like

Here is a suggested approach:

2 Likes

I like that approach and it’s very good but has one drawback in that you can’t have a background image or linear gradients behind the tabs as you are blotting out sections using a solid colour to match the background which you can’t do for an image or linear gradient that sits behind.

If you borrow the box-shadow trick trick from my example you can get rid of the solid background and allow any colour behind.

I hope you don’t mind but I forked your example and added that code in place.:slight_smile:

I also removed the left and right divs and replaced them with pseudo elements to keep the html a little cleaner. My method was using absolute positioning for the corners which is fine but the flex method is a little less complicated.

.

2 Likes

Top ’o the morning gentles (as we say in Shakespearian). Thank you both. Yes that’s the idea Paul however the “slope” is not that acute. I’ll try and hunt down a product image of a manilla folder and report back. I’ll plug in your most recent example Paul and see if I can figure out how modify the slope on my own (highly unlikely!). Now — coffee! Thank you also Archibald, always a learning experience for me to practice with your examples.

Yes that would help as I’m not quite sure if I understand fully. :slight_smile:

You can get a bigger radius at the bottom like this:

.hilitea {
    display:table;
    position:relative;
    margin:auto;
    text-align: center;
    border-radius: 20px 20px 0px 0px;
    color: white;
    background-color: #000000;
    padding-top: .5rem;
    font-family: 'courier prime', monospace;
    font-size: 2.5rem;
    line-height: 2.63rem;
    font-weight: bold;
}
.hilitea:after,
.hilitea:before {
  content: "";
  position: absolute;
  z-index: 2;
  top: 1rem;
  bottom: 0;
  width: 20px;
  box-shadow: 0 10px #000; /* this is necessary or a gap will show */
}
.hilitea:after {
  right: -18px;
}
.hilitea:before {
  left: -18px;
}
.hilitea:after {
  border-radius: 0 0 0 20px;
}
.hilitea:before {
  border-radius: 0 0 20px 0;
}


Take a look at this manila file folder on Amazon: https://amazon.com/AmazonBasics-File-Folders-Manila-36-Pack/dp/B07TLNZTP1/

The shaded portion gives you the best example of the gentle slope effect I’m after. Paul I love that background! That’s so Elizabethan. :slight_smile:

Instead of the edges of the tab dropping acutely at 90° before making their little curve, the edges “slope” to something more like 130°. Pretend you’re drawing a ski slope: pity the skier if he’s suddenly skiing a mountain with a 90° drop!!

This may be too ambitious for CSS. If so, just let me know and I’ll create it as a graphic. I am asking for CSS to draw here . . . :roll_eyes:

Here you go. Actually he’d probably still be dead with this iteration lol but . . . this is what I’m after:

This is getting closer I think.

It’s a bit magic numberish for me and will need testing. :slight_smile:

1 Like

Here’s another approach:

(The 47 is a very magic number :grinning: )

2 Likes

Looks very good :slight_smile:

I’m still not happy with mine as too many magic numbers needed but the html is pretty good.

I need to think about it a bit more :wink:

2 Likes

Paul that first one is almost there! I can’t believe you’re doing this with CSS it takes my breath away. Just amazing. Now let me look at your second one and Archibald’s wizardry. This is amazing . . .

it appears that the use of SVG has not been
suggested as a possible solutuion for the tab.

index.html

<!DOCTYPE HTML>
<html lang="en">
<head>

<meta charset="utf-8">
<meta name="viewport" content="width=device-width,height=device-height,initial-scale=1">

<title>Tomorrow</title>

<link href="https://fonts.googleapis.com/css?family=Courier+Prime" 
 rel="stylesheet" media="screen">
<link href="https://fonts.googleapis.com/css?family=Special+Elite" 
  rel="stylesheet" media="screen">
<link href="screen.css" rel="stylesheet" media="screen">

</head>
<body>

<h1>To-morrow, and to-morrow, and to-morrow,</h1>

<svg xmlns="http://www.w3.org/2000/svg"  
     viewBox="0 0 1034 170"
 >

<g transform="translate(0,170) scale(0.1,-0.1)"
   fill="#000000" 
   stroke="none"
 >

<path d="M2860 1684 c-73 -20 -127 -53 -179 -109 -39 -42 -91 -134 -91 -161 0
-6 -17 -51 -39 -100 -21 -49 -50 -120 -65 -159 -39 -105 -72 -154 -174 -265
-141 -151 -229 -212 -397 -275 -201 -76 -327 -85 -1227 -92 l-688 -4 0 -255 0
-254 5170 0 5170 0 0 255 0 255 -493 0 c-271 0 -551 5 -623 10 -71 6 -205 14
-299 19 -192 11 -301 32 -440 88 -154 62 -234 120 -376 276 -108 119 -131 156
-184 302 -48 134 -130 288 -178 338 -46 46 -135 97 -223 127 -56 20 -100 20
-2333 19 -1971 0 -2283 -2 -2331 -15z"/>
</g>

<text 
   x="280" 
   y="85"
   font-family="Courier Prime"
   font-size="96"  
   fill="#fff"
 >
    &mdash;Creeps&mdash;
</text>
</svg>

</body>
</html>

screen.css

h1 {
   margin: 1.25rem 0;
   font: normal 2.5rem/2.25rem 'Special Elite', serif;
   text-align: center;
 }
svg {
   display: block;
   width: 50%;
   margin: auto;
 }

You may view it here, if interested…

codepen - full Page View

3 Likes

Okay Paul’s first one quite possibly nails it. The artistry — and that is what it is; having a good eye for balancing the slope against the curves — is extremely tricksy: go too far and you’re making ocean waves; don’t go far enough, and you get Archibald’s submission + Paul’s second effort, both of which are too angular.

But I see we have a very special visitor to the thread, with an SVG workaround. Welcome and let me see what kind of trouble we can get into with that noble graphics standard . . .

semicodin

I had considered using an SVG for the tab (or using CSS clip-path for the whole tab) but by using a CSS Flexbox container, the tab width will automatically adjust according to the length of text put in the tab (without distorting the curves).

1 Like

snadyleiby first, you get the semicodin prize for posting your code in one. complete. block. of code. I’m forced for reasons I won’t go into to using a SmartPhone to code on. It is a misery to work with text that has been amputated for later reassembly: Code-bloody-pen. Oh I have no problem with Codepen on a desktop; on a phone it is sheer misery. My fat fingers thank you.

Your submission is close . . . but still too acute for this project. Look at Paul’s first submission and be careful with balancing the slope against the curves. This is hard! This is really hard. That’s why I hunted down an image so anyone interested in taking a stab at this will have at least some starting point. Leave it to Paul to come this far and still not be satisfied! He is the Elder Statesman of Sitepoint imho.

I am very interested in your approach to this project snadyleiby and hope you’ll stay with it? With some tweaking I hope you’ll get it to Paul’s standard. SVG is nothing short of amazing and I’d love to have both technologies in my tool chest. :wink:

One last thing: This project happens to be for one tab; when you put together a row of these they are absolutely gorgeous. Decades and decades ago some artist came up with the design that still dominates today. Here in the United States there almost isn’t a brand of file folders that doesn’t use the same original template, probably created 100 years ago! There will be a time when I’ll be ready to line these beauties up in a row but that’s a long way off. Right now I only have need of the one.

semicodin
only semi talented at coding :wink:

That’s brilliant Archibald. I love how you and Paul are building this to be a template that can take background images . . . and absolutely be able to <——expand——>! I hadn’t even thought of that but of course it will need to be expandable.

Well Paul using your first version (#95 in my naming convention) I just had to make two tweaks to get it to make nice with my original code (which I can’t post here at Sitepoint because it’s political) namely:
width-max: I had to remove it from the body tag because it broke the page. It now is just width: 950px . . . and I expanded your width-max on your .tab style to 600px (you had 500).

However I don’t know how to get the edges straight just below the tab — the black border that is what the tab slopes into. They’re curiously angled. This is such a thrill! I wish I could post the original. :slight_smile: