comato
comato

Reputation: 3

css square border with gap in border bottom

I'm trying to replicate this mock up design.

Design:

Mock up design

Current:

current progress

Is there a way to make sure the "Shop All" ignores the overflow:hidden, but the before and after obey the overflow:hidden?

Or is there another method I can try to implement this?

Html

<div id="outer">
  <div id="opaq">
  <div id="inner">
    <h1>Performance Parts</h1>
    <p>Lorem ipsum dolor sit amet, consectetur adipiscing elit. Morbi efficitur in arcu at placerat. Aenean sed lorem tincidunt, maximus purus eget, ornare metus. Nam interdum lobortis imperdiet. Nunc gravida urna urna. Vestibulum vitae lectus leo. Etiam fermentum nunc vel nulla tincidunt, sit amet molestie lectus pulvinar.</p>
    <div id="shop">Shop all</div>
  </div>
  </div>  
</div>

Css

#outer{
  max-width:500px;
  text-align:center;
  background-image: url("https://encrypted-tbn0.gstatic.com/images?q=tbn:ANd9GcRNyPOuKMHtvXNa5dnlc8xGXvW-nVfguLdlj9sj4-K6cTA0Zbf7");

}
#opaq{
  background-color: rgba(48, 44, 44, 0.7);
  padding:5px;
}
#inner{
  border:1px solid red;
  margin:10px;
  color:white;
  border-bottom:none;
  overflow:hidden;
}

#shop{
  position:relative;
  top:8px;
  display: inline-block;
}
#shop:after{
  content: "";
  position: absolute;
  border-bottom: 1px solid white;
  top: 9px;
  width: 600px;
  left: 100%;
  margin-left: 15px;
}
#shop:before{
  content: "";
  position: absolute;
  border-bottom: 1px solid white;
  top: 9px;
  width: 600px;
  right: 100%;
  margin-right: 15px;
}

Upvotes: 0

Views: 3772

Answers (4)

G-Cyrillus
G-Cyrillus

Reputation: 106038

You may try a negative margin and some flex to draw side borders, and it will keep a coherent HTML with title coming first in the code :

div {
  margin:2em;
  display:flex;
  flex-flow:column;
  text-align:center;
  border:solid;
  border-bottom-color:transparent;
  background:rgba(0,0,0,0.2);
  box-shadow: 0 0 0 2em rgba(0,0,0,0.2);
  }
div h2 {
  order:1;
  display:flex;
  margin:0 0 -0.6em 0;
  font-variant:small-caps;
  }
h2:before,
h2:after {
  content:'';
  flex:1;
  border-bottom:solid;
  margin:auto 1em auto -3px ;
  }
  h2:after {
  margin: auto -3px auto 1em;
    }
  p {padding:0.25em 0.5em;}
  html {background:url(http://lorempixel.com/800/600/city/6);
  background-size:cover;
  color:white;
  text-shadow:0 0 1px black;
  }
<div>
  <h1>HTML Ipsum Presents</h1>
  <h2>shop all</h2>
  <p><strong>Pellentesque habitant morbi tristique</strong> senectus et netus et malesuada fames ac turpis egestas. Vestibulum tortor quam, feugiat vitae, ultricies eget, tempor sit amet, ante. Donec eu libero sit amet quam egestas semper. <em>Aenean ultricies mi vitae est.</em> Mauris
    placerat eleifend leo. Quisque sit amet est et sapien ullamcorper pharetra. Vestibulum erat wisi, condimentum sed, <code>commodo vitae</code>, ornare sit amet, wisi. Aenean fermentum, elit eget tincidunt condimentum, eros ipsum rutrum orci, sagittis
    tempus lacus enim ac dui. <a href="#">Donec non enim</a> in turpis pulvinar facilisis. Ut felis.</p>
  <p>Pellentesque habitant morbi tristique senectus et netus et malesuada fames ac turpis egestas. Vestibulum tortor quam, feugiat vitae, ultricies eget, tempor sit amet, ante. Donec eu libero sit amet quam egestas semper. Aenean ultricies mi vitae est.
    Mauris placerat eleifend leo.</p>
</div>

Upvotes: 0

sezanzeb
sezanzeb

Reputation: 1139

border split into table cells:

	body
	{
		font-family:arial;
		background-image:url("https://encrypted-tbn0.gstatic.com/images?q=tbn:ANd9GcRNyPOuKMHtvXNa5dnlc8xGXvW-nVfguLdlj9sj4-K6cTA0Zbf7");
		background-size:cover;
		margin:0px;
	}

	.box div
	{
		border:0px solid RGBa(255,255,255,0.5);
	}

	.shade
	{
		background-color:RGBa(50,50,50,0.7);
		padding:20px;
		position:fixed;
		top:0px;
		right:0px;
		bottom:0px;
		left:0px;
	}

	h1
	{
		text-align:center;
		text-transform:uppercase;
	}

	.bottomborder
	{
		display:table;
		table-layout:fixed;
	}

	.box .left
	{
		width:50%;
		border-width:0px 0px 2px 2px;
	}

	.box .right
	{
		width:50%;
		border-width:0px 2px 2px 0px;
	}

	.box .col
	{
		display:table-cell;
	}

	.shopall
	{
		padding: 0px 15px;
		white-space: nowrap;
		position: relative;
		top: 10px;
		color:RGB(200,150,0);
		font-weight:bold;
		font-size:20px;
		text-transform:uppercase;
	}

	.box
	{
		margin-left:auto;
		margin-right:auto;
		width:1100px;
		margin-top:15px;
		max-width: 100%;
	}

	.box .content
	{
		padding:5px 55px 10px 55px;
		border-width:2px 2px 0px 2px;
		border-top-left-radius:0px;
		border-top-right-radius:0px;
		color:white;
	}
<body>
	<div class="shade">
		<div class="box">
			<div class="content">
				<h1>Performance & Parts </h1>
				Lorem ipsum dolor sit amet, consectetur adipiscing elit. Morbi efficitur in arcu at placerat. Aenean sed lorem tincidunt, maximus purus eget, ornare metus. Nam interdum lobortis imperdiet.
			</div>
			<div class="bottomborder">
				<div class="left col">
				</div>
				<div class="col">
					<div class="shopall">
						shop all
					</div>
				</div>
				<div class="right col">
				</div>
			</div>
		</div>
	</div>
</body>

Upvotes: 0

SolE-pAt21
SolE-pAt21

Reputation: 38

Use this css; notice i have added comments to the code i change or added

    #outer{
  max-width:500px;
  text-align:center;
  background-image: url("https://encrypted-tbn0.gstatic.com/images?q=tbn:ANd9GcRNyPOuKMHtvXNa5dnlc8xGXvW-nVfguLdlj9sj4-K6cTA0Zbf7");

}
#opaq{
  background-color: rgba(48, 44, 44, 0.7);
  padding:5px;
}
#inner{
  border:1px solid red;
  margin:10px;
  color:white;
  border-bottom:none;


}

#shop{
  position:relative;
  top:8px;
  display: inline-block;
  z-index:200; /*added*/



}
#shop:after{
  content: "";
  position: absolute;
  border-bottom: 1px solid white;
  top: 9px;
  width: 364%; /* changed */
  left: 100%;
  margin-left: 15px;

}
#shop:before{
  content: "";
  position: absolute;
  border-bottom: 1px solid white;
  top: 9px;
  width: 364%; /* changed */
  right: 100%;
  margin-right: 15px;

}

Upvotes: 0

Andrei Fedorov
Andrei Fedorov

Reputation: 3987

* {
  margin: 0;
  padding: 0;
  font-family: sans-serif;
}
.wrapper {
  background-image: linear-gradient(rgba(0, 0, 0, .3), rgba(0, 0, 0, .3)), url(http://beerhold.it/400/300);
  background-repeat: no-repeat;
  background-size: cover;
  width: 400px;
  height: 200px;
  box-sizing: border-box;
  display: flex;
  align-items: center;
  justify-content: center;
}
fieldset {
  width: 90%;
  height: 90%;
  margin-top: .7em;
  transform: rotate3d(0, 0, 1, 180deg);
  border: 3px solid rgba(255, 255, 255, .4);
}
legend {
  font-size: 1.4em;
  font-weight: 700;
}
legend span,
fieldset .text {
  display: block;
  transform: rotate3d(0, 0, 1, 180deg);
  color: white;
  text-shadow: 0 0 4px black;
  padding: 0 1em;
}
legend span {
  color: yellow;
}
fieldset .text {
  height: 100%;
}
fieldset .text h1 {
  padding: .3em 0;
  text-align: center;
}
fieldset .text p {
  line-height: 1;
}
<div class="wrapper">
  <fieldset>
    <legend align="center"><span>SHOP ALL</span>
    </legend>
    <div class="text">
      <h1>Lorem ipsum</h1>
      <p>Lorem ipsum dolor sit amet, consectetur adipiscing elit. Ut a justo nisl. Phasellus consequat tincidunt elit, sed interdum nibh blandit ut. Nunc augue erat, rutrum ac vehicula nec, pulvinar in eros.
      </p>
    </div>
  </fieldset>
</div>

Upvotes: 4

Related Questions