I have a div table which has a lot of content inside, because of that I added overflow:hidden so the table is scrollable.
Inside I have an info link which on hover displays some additionally information.
The problem is, the info box on the first row of the table is most likely outside of the table and this piece gets cut off.
How to make this hidden piece infobox outside of the table visible, without removing overflow:hidden or using JS?
.outertable{
display:block;
overflow-x:auto !important;
}
.info:hover:after{
background: rgba(75,75,75, 0.85);
bottom: 32px;
color: #fff;
content: attr(data-tooltip);
left: -100px;
position: absolute;
z-index: 999;
width: 200px;
}
Here is some small example on jsfiddle:
https://jsfiddle.net/0tcbadk8/10/
.outertable {
box-shadow: 3px 3px 7px -3px rgba(0, 0, 0, 0.30);
display: block;
overflow-x: auto !important;
}
div.table {
display: table;
width: 100%;
background-color: rgba(0, 0, 0, 0.3);
border-radius: 10px;
}
div.tr {
display: table-row;
}
div.maintr {
display: table-row;
}
.maintr .td {
padding: 15px 5px;
}
div.td {
display: table-cell;
padding: 10px 5px;
text-align: center;
vertical-align: middle;
}
.info {
display: inline;
position: relative;
}
.info:hover:after {
background: #333;
background: rgba(75, 75, 75, 0.85);
border-radius: 5px;
bottom: 32px;
color: #fff;
content: attr(data-tooltip);
left: -100px;
padding: 15px 25px;
position: absolute;
z-index: 999;
width: 200px;
}
.info:hover:before {
border: solid;
border-color: #4b4b4b transparent;
border-width: 12px 12px 0 12px;
bottom: 20px;
content: "";
left: 0%;
position: absolute;
z-index: 99;
}
<br/><br/><br/><br/><br/><br/>
<div class="outertable">
<div class="table offerstyle">
<div class="tr">
<div class="td fixinfonooverflow"></div>
<div class="td"></div>
<div class="td"></div>
<div class="td"></div>
<div class="td"></div>
</div>
<div class="tr">
<div class="td"><img class="" data-original="images/logo/3.png" title="" alt="" src="images/logo/3.png" style=""></div>
<div class="td">BLABLABLA</div>
<div class="td">
<div class="nonewline more_info" title="4.8 von 5 Sternen und 5 Bewertungen"><i class="fa fa-star ratingtwo" aria-hidden="true"></i><i class="fa fa-star ratingtwo" aria-hidden="true"></i><i class="fa fa-star ratingtwo" aria-hidden="true"></i><i class="fa fa-star ratingtwo" aria-hidden="true"></i><i class="fa fa-star-half-o ratingtwo"
aria-hidden="true"></i></div>
</div>
<div class="td">
<a class="info" data-tooltip="Lorem ipsum dolor sit amet, consectetur adipiscing elit. Pellentesque a est ut justo interdum efficitur at id tortor. Cras lacinia, sapien sit amet suscipit sodales, mi velit bibendum risus, at dictum ligula mauris vel dui."><i class="fa fa-info-circle" aria-hidden="true"></i> info</a>
</div>
<div class="td">TEST<br>TEST2<br>TEST3<br></div>
</div>
<div class="tr">
<div class="td fixinfonooverflow"></div>
<div class="td"></div>
<div class="td"></div>
<div class="td"></div>
</div>
</div>
</div>
I see 3 options:
1) If you know the contents of the info box and the content is fixed size you could increase the spacing of the table to accommodate the size of the info box to stay "inside".
2) Quick solution: Instead of position: absolute you could use position: fixed on the info box, this works if it fits your needs (won't scroll with the content, it will stay fixed).
.info:hover:after{
background: #333;
background: rgba(75,75,75, 0.85);
border-radius: 5px;
color: #fff;
content: attr(data-tooltip);
left: 400px;
top: 0;
padding: 15px 25px;
position: fixed;
z-index: 999;
width: 200px;
}
.info:hover:before{
border: solid;
border-color: #4b4b4b transparent;
border-width: 12px 12px 0 12px;
content: "";
left: 420px;
top: 173px;
position: fixed;
z-index: 99;
}
Updated jsfiddle: https://jsfiddle.net/0tcbadk8/27/
3) Create the info box dynamically using jQuery / Javascript and position it depending on the position of the trigger element and checking if it overflows outside of boundaries of the table and reposition it. In the same time it could be place outside of overflow:hidden container in markup.
Demo :
https://jsfiddle.net/0tcbadk8/56/
Explanation:
You need to remove position: relative from parent in order to make it pop out of overflow: hidden
But now we cannot use top,right,bottom or left because that won't be relative to parent but will be relative to body
So in order to position them with translate and margin only
I will also require the width of owner of pseudo elements
So added JS which adds a --width css variable
Using some basic logic and maths, added the translateX and translateY to the pseudo elements
PS:
Here's a css only solution http://jsfiddle.net/keygcptw/1/ But the only problem is tooltip is positioned on extreme right instead of center
Related
I want to add a small horizontal line like the one on the page.
I tried using the <hr\> tag but i don't get the desired line, is there any other way to add this line.
The code below describes what i've done so far to construct the line but i have not been able to achieve it.
Please could someone help me create the line
Thanks
.second-bg-cover{
background-image: linear-gradient(rgba(0, 0, 0, 0.7),rgba(0, 0, 0, 0.5)) ,url(../img/state1.jpg);
width: 100%;
height: 320px;
background-repeat: no-repeat;
position: relative;
z-index: -1;
}
.second-cover-heading {
position: absolute;
z-index: 1;
padding: 60px 0;
color: var(--white);
}
.second-cover-photo-section h1{
font-family: 'Raleway',sans-serif;
font-weight: 400;
}
.second-cover-download{
background: transparent;
color: white;
padding: 8px 18px;
border-color: var(--white);
position: relative;
z-index: 2;
}
.second-cover-download{
margin-left:580px;
margin-top: 25px;
}
<div class="row">
<div class="col-md-12">
<div class="second-bg-cover"></div>
</div>
<div class="col-md-12 second-cover-heading">
<h1 class="text-center">STYLISH AXURE DESIGN</h1>
<hr style="width:80px;height:2px;text-align:left;margin-left:660px;border: 1.5px solid white; color: white;">
<p class="text-center mt-4">Use the selections you need, remove the lines you don't need.Create gorgeous prototypes faster than ever!
</p>
<div class="second-cover-download">
<button class="second-cover-download ms-5" type="button">Download</button>
</div>
</div>
</div>
You can use the ::after like this:
HTML:
<h1 class="text-center with_underline">STYLISH AXURE DESIGN</h1>
CSS:
.with_underline::after{
content: "";
height: 3px;
width: 120px;
background: red;
display: block;
margin: 0 auto;
margin-top: 10px;
}
Here's the fiddle: https://jsfiddle.net/43e6r07m/
You can use the hrtag to create a line, or create a class named "spacer" that will allow you to customize the line. For example :
.spacer{
width:100%;
border:2px solid rgba(0,0,0,0.2);
margin:0;
box-sizing: border-box;
}
.myContainer{
width:80%;
margin-left:auto;
margin-right:auto;
}
<div class="myContainer">
Lorem ipsum dolor sit amet...
<div class="spacer"></div>
</div>
I am learning HTML and CSS and I am having difficulty centering a button within a <div>. Here is the code I currently have:
.box-information {
border: 2px solid #000000;
margin: 0 auto 15px auto;
padding: 0 10px 60px 10px;
width: 80%;
background-color: #ffffff;
position: relative;
}
.button-blue:link,
.button-blue:visited {
width: 7em;
display: block;
padding: 10px 15px;
background-color: rgba(66, 85, 123, 1);
font-size: 1.0em;
text-indent: 0;
text-align: center;
color: #ffffff;
position: absolute;
bottom: 10px;
left: auto;
}
<div class="box-information your-business">
<p class="title-information">
Your Business
</p>
<p class="text-information">
Lorem ipsum dolor sit amet, consectetur adipiscing elit.
</p>
<a class="button-blue learn-more" href="#">Learn More</a>
</div>
I am able to offset the button from the bottom, and I can offset the button horizontally if I use anything but AUTO.
Please help me understand what I am doing wrong.
To center a block element in it's parent, all you need to do is add:
margin-left:auto;
margin-right:auto;
to the button's CSS properties.
(You will need to remove the position: absolute and the absolute positioning properties first.)
Take a look at this codepen: https://codepen.io/anon/pen/qXYEpd
Update
.box-information {
border: 2px solid #000000;
margin: 0 auto 15px auto;
padding: 0 10px 60px 10px;
width: 80%;
background-color: #ffffff;
position: relative;
}
.button-blue:link,
.button-blue:visited {
width: 7em;
display: block;
padding: 10px 15px;
background-color: rgba(66, 85, 123, 1);
font-size: 1.0em;
text-indent: 0;
text-align: center;
color: #ffffff;
position: absolute;
bottom: 10px;
left: 50%;
transform: translateX(-50%);
}
<div class="box-information your-business">
<p class="title-information">
Your Business
</p>
<p class="text-information">
Lorem ipsum dolor sit amet, consectetur adipiscing elit.
</p>
<a class="button-blue learn-more" href="#">Learn More</a>
</div>
Set margin-left:50%;. This set my button to the middle of its parent control.
I'm attempting to make a webpage where there are several images as links for visiting separate pages, and I want to make a popup show next to the image with a summary, title, and other details of the page in HTML (maybe a button "Read More" or something). I'm trying to create a popup similar to
this one:
I've got my images already, and I can't find a template where there's a separate popup next to the image, because all the image css transition links have the title and text inside the image rather than next to it as a popup. Is this to complicated to do in CSS, or is it possible?
Thanks in advance! If there is any need for clarification in my question, please ask!
<a href="SecretPlants.html">
<img class="imgLinks" src="file:///E:/Grace/Art/Animation-Computing/Website/ContentTABS/ResourceFiles/Literature/TheSecretsHeldInPlants/SecretLifeofPlantsCover.jpg" alt="Link to Plants Research Paper" height="300">
<a href="EmbraceDifferences.html">
<img class="imgLinks" src="Embrace Differences Cover Image.jpg" alt="Link to Plants Research Paper" height="300">
<a href="Teams of Teams, Hierarchy of Teams, and Hierarchy Essay.html">
<img class="imgLinks" src="Cover.jpg" alt="Link to Hierarchy and Team Critical Essay" height="300">
I create an example for you, hopefully it can usefull for you :
HTML :
<div class="button">
<img class="parentPic" src="http://lorempixel.com/400/200/sports/1" alt"test" />
<section class="speech">
<div class="row">
<div class="col-md-2"></div>
<div class="col-md-8">
<div class="list-group">
<a href="#" class="list-group-item active">
<h4 class="list-group-item-heading">List group item heading</h4>
<p class="list-group-item-text">Lorem Ipsum is simply dummy text of the printing and typesetting industry. Lorem Ipsum has been the industry's standard dummy text ever since the 1500s, when an unknown printer took a galley</p>
</a>
</div>
<div class="well well-sm">Lorem Ipsum has been the industry's standard dummy text ever since the 1500s, when an unknown</div>
<ul class="list-group">
<li class="list-group-item">
<span class="badge">14</span>
Cras justo odio
</li>
</ul>
</div>
<div class="col-md-2"></div>
</div>
</section>
</div>
CSS :
.button {
position: relative;
}
.button > img {
display: inline-block;
color: #fff;
padding: 0.4em 0.6em;
font-size: 1.3em;
}
.button section {
display: none;
position: absolute;
top: 2em;
left: 32em;
padding: 20px;
margin: 0;
border: 5px solid #fd0;
background: white;
border-radius: 1em;
}
.button section > p {
display:block;
text-align:center;
}
}
.button .parentPic {
display: block;
border-radius: 0.8em;
max-width: 100%;
height: auto;
}
.button:focus section,
.button:hover section {
display: inline-flex;
top:0px;
}
.speech {
position: relative;
width: 300px;
height: 400px;
text-align: center;
line-height: 20px;
background-color: white;
border: 8px solid #fd0;
-webkit-border-radius: 30px;
-moz-border-radius: 30px;
border-radius: 30px;
-webkit-box-shadow: 2px 2px 4px #888;
-moz-box-shadow: 2px 2px 4px #888;
box-shadow: 2px 2px 4px #888;
}
.title{
text -align:center;
}
.speech > p{
padding:15px;
}
.speech:before {
content: ' ';
position: absolute;
width: 0;
height: 0;
left: 0px;
border: 0px solid;
border-color: #fd0 transparent transparent #fd0;
}
.speech:after {
content: '';
position: absolute;
width: 0;
height: 0;
left: -29px;
top: 50px;
border-top: 13px solid;
border-left: 25px solid;
border-right: 3px solid;
border-top-left-radius: 39px;
border-bottom-left-radius: 41px;
border-color: #fd0 transparent transparent #fd0;
}
https://jsfiddle.net/emilvr/9x7j430L/3/
You can just make the popup div with position:absolute and not setting its coordinate to make it popup next to it
for example this one is done without using javascript, using css a:hover
<html>
<head>
<style>
#popup0 {
visibility:hidden;
position:absolute;
z-index:1;
}
#link0 {
display:inline;
}
#popup0 {
display:inline;
}
#link0:hover #popup0{
visibility:visible;
position:absolute;
}
#something {
display:inline;
}
</style>
</head>
<body>
<a href="" id="link0">
hover here
<img id="popup0" src="yourfile.png" />
</a>
<div id="something">
other things next to it
</div>
</body>
</html>
Good day! I'm having a struggle to aligned the jumbtron to my calendar icon. And the elements of the jumbtron is not inside of it. Can someone help me how to solve this? Ideas? i just started studying bootstrap and css.
Here's the picture.
here is my html code.
<div class="events">
<div class="container">
<div class="row">
<div class= "col-sm-4 col-xs-25">
<h4 id="event"><i class="fa fa-calendar" aria-hidden="true"></i> Upcoming Events</h4>
<hr class="carved">
<div class="date">
<span class="month">August</span>
<h1 class="day">28</h1>
</div>
<div class="container">
<div class="jumbotron">
<h4>Sample Title</h4>
<p>IT Thesis defense</p>
<h6>7:00 AM - 8:00 PM</h6>
</div>
</div>
<hr class="divider">
<div class="date">
<span class="month">August</span>
<h1 class="day">28</h1>
</div>
<hr class="divider">
<div class="date">
<span class="month">August</span>
<h1 class="day">28</h1>
</div>
</div>
<div class= "col-sm-8 col-xs-25">
<h4 id="event"><i class="fa fa-newspaper-o" aria-hidden="true"></i> Latest News</h4>
<hr class="carved">
</div>
</div>
</div>
</div>
here is my css
#event {
color: #a92419;
}
hr.carved {
clear: both;
float: none;
width: 100%;
height: 2px;
border: none;
background: #ddd;
background-image: -webkit-gradient(
linear,
left top,
left bottom,
color-stop(0.5, rgb(126,27,18)),
color-stop(0.5, rgb(211,45,31))
);
background-image: -moz-linear-gradient(
center top,
rgb(126,27,18) 50%,
rgb(211,45,31) 50%
);
}
.date {
display: block;
width: 60px;
height: 60px;
margin-bottom: 20px;
background: #fff;
text-align: center;
font-family: 'Helvetica', sans-serif;
position: relative;
}
.date .month {
background: #a92419;
display: block;
padding-bottom: 5px;
padding-top: 5px;
color: #fff;
font-size: 10px;
font-weight: bold;
border-bottom: 2px solid #a92419;
box-shadow: inset 0 -1px 0 0 #a92419;
}
.date .day {
display: block;
margin: 0;
padding-bottom: 10px;
padding-top: 5px;
text-align: center;
font-size: 20px;
color:#a92419;
box-shadow: 0 0 3px #ccc;
position: relative;
}
.date .day::after {
content: '';
display: block;
height: 95%;
width: 96%;
position: absolute;
top: 3px;
left: 2%;
z-index: -1;
box-shadow: 0 0 3px #ccc;
}
.date .day::before {
content: '';
display: block;
height: 90%;
width: 90%;
position: absolute;
top: 6px;
left: 5%;
z-index: -1;
}
.jumbotron {
width: 300px;
height: 100px;
margin:none;
}
.jumbotron p {
font-size:12px;
}
The .container class carries its own width(s) and is intended to be used as a outer wrapper for your layout. Because of this, they do not tend to nest well. The one you have as a sibling of your .date classed elements is breaking the layout.
As for the spacing of the .jumbotron contents, Bootstrap assigns some pretty dramatic padding to that class by default. Consider overwriting that with your own values in your .jumbotron rule. The other issue — the .jumbotron contents bleeding out of their container — that is a result of the height: 100px you are setting. You can stop the contents from taking up space beyond the boundaries of the .jumbotron by adding/modifying its overflow property. This may be a matter of opinion but I think it is usually better to avoid setting height in the CSS and let the contents define the size of the container — especially in cases where the content is CMS/client driven.
If you remove the .container, you’ll still have the problem of the .date and .jumbotron stacking vertically. To address that, you might consider treating Date element as .row with a column for your .date element, and a column for that Date’s event(s).
<hr class="carved">
<div class=“row”><!-- the Date wrapper -->
<div class="col-sm-4">
<div class="date">
<span class="month">August</span>
<h1 class="day">28</h1>
</div>
</div>
<div class="col-sm-8"><!-- this column holds all the Events for this Date -->
<div class="jumbotron">
<h4>Sample Title</h4>
<p>IT Thesis defense</p>
<h6>7:00 AM - 8:00 PM</h6>
</div>
</div>
</div>
Note: The new structure will require a bit of adjustment to some of your CSS width properties, and the col- device/sizes I put on the Date and Event columns are just examples — size as needed.
<div class="container">
<div class="row">
<div class="col-md-2">
<h4 id="event"><i class="fa fa-calendar" aria-hidden="true"></i> Upcoming Events</h4>
<hr class="carved">
<div class="date">
<span class="month">August</span>
<h1 class="day">28</h1>
</div><!-- date -->
</div><!-- md2 -->
<div class="col-md-10">
<h4 id="event"><i class="fa fa-newspaper-o" aria-hidden="true"></i> Latest News</h4>
<hr class="carved">
<div class="jumbotron">
<h4>Sample Title</h4>
<p>IT Thesis defense</p>
<h6>7:00 AM - 8:00 PM</h6>
</div><!-- jumbo -->
</div><!-- md10 -->
</div><!-row>
</div><!-- container -->
+
#event {
color: #a92419;
}
hr.carved {
clear: both;
float: none;
width: 100%;
height: 2px;
border: none;
background: #ddd;
background-image: -webkit-gradient(
linear,
left top,
left bottom,
color-stop(0.5, rgb(126,27,18)),
color-stop(0.5, rgb(211,45,31))
);
background-image: -moz-linear-gradient(
center top,
rgb(126,27,18) 50%,
rgb(211,45,31) 50%
);
}
.date {
display: block;
width: 60px;
height: 60px;
margin-bottom: 20px;
background: #fff;
text-align: center;
font-family: 'Helvetica', sans-serif;
position: relative;
}
.date .month {
background: #a92419;
display: block;
padding-bottom: 5px;
padding-top: 5px;
color: #fff;
font-size: 10px;
font-weight: bold;
border-bottom: 2px solid #a92419;
box-shadow: inset 0 -1px 0 0 #a92419;
}
.date .day {
display: block;
margin: 0;
padding-bottom: 10px;
padding-top: 5px;
text-align: center;
font-size: 20px;
color:#a92419;
box-shadow: 0 0 3px #ccc;
position: relative;
}
.date .day::after {
content: '';
display: block;
height: 95%;
width: 96%;
position: absolute;
top: 3px;
left: 2%;
z-index: -1;
box-shadow: 0 0 3px #ccc;
}
.date .day::before {
content: '';
display: block;
height: 90%;
width: 90%;
position: absolute;
top: 6px;
left: 5%;
z-index: -1;
}
Result
You can't have two legends for a given fieldset, but is there a way to get a legend effect without using the <legend> tag?
<!-- left legend -->
<fieldset>
<legend>
Some Text
</legend>
</fieldset>
I can add align=right to the legend tag to make it on the right-hand side, but again, I can't have two legends. I'd like to have a legend to the left, and something like a legend to the right. Something like the image below.
How can I accomplish this using HTML and CSS? Here's a Fiddle, I basically want to combine these two. On the left would be regular legend text, and to the right would be a dropdown if it matters.
Update
Here's some code I'm working with :
#shifter {
position: relative;
}
#cataright {
position: absolute;
top: -25px;
right: 20px;
font-weight: bold;
}
.grey {
padding: 15px;
padding-left: 30px;
padding-right: 30px;
border: solid black 3px;
border-radius: 7px;
background-color: #DDDDDD;
}
<fieldset class="grey" id="shifter">
<legend>
Title
</legend>
<div id="cataright">
Sort by
<select id="sort" onchange="sort();">
<option value="original">Release Date</option>
<option value="popularity">Popularity</option>
<option value="rating">Highest Rated</option>
</select>
</div>
</fieldset>
You can do that by adding an extra element and positioning it absolutly in the <fieldset> :
fieldset {
position: relative;
}
.legend2 {
position: absolute;
top: -0.2em;
right: 20px;
background: #fff;
line-height:1.2em;
}
<fieldset>
<legend>
Some Text
</legend>
<div class="legend2">Some other Text</div>
</fieldset>
You can use :after pseudo selector to achieve this. SEE THE DEMO.
This way, you don't have to use any additional html tags.
fieldset {
position: relative;
}
fieldset:after {
content: "Some Text";
position: absolute;
margin-top: -25px;
right: 10px;
background: #fff;
padding: 0 5px;
}
I had the same problem, but the answers here did not satisfy me. So I developed my own solution.
My solution is based on div-Tags. Just play with the width of the legend Tag and the width of the div Tag. Also you can set more Text.
Beneath you can find three different examples.
<fieldset style="border: 1px solid black; width: 500px; height: 100px; margin: 1em auto;">
<legend style="width: 100%; padding: 0;">
<div style="display: inline-block; line-height: 1.2;">
<div style="float: left; padding: 0 5px;">Legend</div>
<div style="float: left; height: 1px; background-color: black; width: 359px; margin-top: 11px;"></div>
<div style="float: left; padding: 0 5px;">Other Stuff</div>
</div>
</legend>
</fieldset>
<fieldset style="border: 1px solid black; width: 500px; height: 100px; margin: 1em auto;">
<legend style="width: 81%; padding: 0;">
<div style="display: inline-block; line-height: 1.2;">
<div style="float: left; height: 1px; background-color: black; width: 78px; margin-top: 11px;"></div>
<div style="float: left; padding: 0 5px;">Legend</div>
<div style="float: left; height: 1px; background-color: black; width: 186px; margin-top: 11px;"></div>
<div style="float: left; padding: 0 5px;">Other Stuff</div>
</div>
</legend>
</fieldset>
<fieldset style="border: 1px solid black; width: 500px; height: 100px; margin: 1em auto;">
<legend style="width: 90%; padding: 0;">
<div style="display: inline-block; line-height: 1.2;">
<div style="float: left; height: 1px; background-color: black; width: 39px; margin-top: 11px;"></div>
<div style="float: left; padding: 0 5px;">Legend</div>
<div style="float: left; height: 1px; background-color: black; width: 88px; margin-top: 11px;"></div>
<div style="float: left; padding: 0 5px;">More Stuff</div>
<div style="float: left; height: 1px; background-color: black; width: 102px; margin-top: 11px;"></div>
<div style="float: left; padding: 0 5px;">Other Stuff</div>
</div>
</legend>
</fieldset>
Note: display inline-block and line-height: 1.2 are necessary for cross browser compatibility.
Ok, I've managed to do it without the background color "hack", or using the fieldset tag,
The only caveat is that trying to get rounded corners may be a bit tricky.
Basically our "panel" will be a box where we draw its left, bottom and right borders.
Then our "panel-title" element will be absolutely positioned at the top of the panel.
Each panel span takes up exactly 50% of the panel width and uses display flex to do the magic. For the first span, we use the before element to draw the border 1em in width from the left-hand side, and then the after element we set the "flex-grow: 1" to tell it to take up the rest of the space.
Then we do exactly the same for the last span except having the width and flex-grow properties reversed.
i.e. the last span's before element will instead be set to flex-grow: 1 and its after element will have a width of 1em.
Anyway, check the snippet below.
* {
box-sizing: border-box;
}
body {
background:url(https://4.bp.blogspot.com/_AQ0vcRxFu0A/S9shDGGyMTI/AAAAAAAAAYk/kn3WTkY2LoQ/s1600/IMG_0714.JPG);
background-size:cover;
background-position:center center;
background-attachment:fixed;
margin: 0;
font-family: 'Roboto Slab';
}
.panel {
background: rgba(0,0,0,0.8);
width: 75vw;
height: -webkit-max-content;
height: max-content;
position: absolute;
top: 50%;
left: 50%;
transform: translate(-50%, -50%);
color: #fff;
padding: 0.5em 1em;
border-left: 1px solid #fff;
border-bottom: 1px solid #fff;
border-right: 1px solid #fff;
}
.panel-title {
display: flex;
position: absolute;
left: 0;
right: 0;
top: -25px;
height: 30px;
line-height:30px;
font-size: 30px;
white-space: nowrap;
text-shadow: 2px 2px 1px rgba(0,0,0,0.8);
}
.panel-title > span {
display: flex;
width: 50%;
}
.panel-title > span:before,
.panel-title > span:after {
content: '';
border-bottom:1px solid #fff;
margin-bottom:5px;
align-self:flex-end;
}
.panel-title > span:first-child:before {
width: 1em;
margin-right: 5px;
}
.panel-title > span:first-child:after {
margin-left: 5px;
flex-grow: 1;
}
.panel-title > span:last-child:before {
flex-grow: 1;
margin-right: 5px;
}
.panel-title > span:last-child:after {
width: 1em;
margin-left: 5px;
}
<link href='https://fonts.googleapis.com/css?family=Roboto+Slab:400,700' rel='stylesheet' type='text/css'>
<div class='panel'>
<DIV class='panel-title'>
<SPAN>Foo Bar</SPAN>
<SPAN>Snee</SPAN>
</DIV>
<P>Lorem ipsum dolor sit amet, consectetur adipiscing elit. Praesent posuere tempus mauris at tincidunt.</P>
<P>Phasellus facilisis leo tortor, nec molestie purus dignissim non. Integer massa turpis, porta sed erat sed.</P>
</div>
Here is a responsive version using Bootstrap.
The custom CSS pushes the second legend up into place.
.legend {
position: relative;
top: -3.4em;
margin-bottom: -3.4em;
}
<link href="https://cdn.jsdelivr.net/npm/bootstrap#5.0.2/dist/css/bootstrap.min.css" rel="stylesheet" integrity="sha384-EVSTQN3/azprG1Anm3QDgpJLIm9Nao0Yz1ztcQTwFspd3yD65VohhpuuCOmLASjC" crossorigin="anonymous">
<fieldset class="container border">
<legend class="float-none w-auto p-2">Legend 1</legend>
<div class="row legend">
<div class="col-12">
<span class="p-2 bg-white float-end">
Legend 2
<select></select>
</span>
</div>
</div>
</fieldset>