I have a hero image that has an overlapping box and I'm trying to add content outside of the box. However when I try to add any content below the overlapping box the content shows up behind the box instead of below. How can I make the content show below the box with responsiveness in mind?
.shell {
display: flex;
flex-direction: column;
align-items: center;
position: relative;
}
/* overlap */
.shell:before {
content: "";
background-image: url(https://i.ibb.co/x866XdV/test-hero.jpg);
background-repeat: no-repeat;
background-size: cover;
background-position: bottom;
position: relative;
height: 300px;
width: 100%;
}
.shell-header {
color: #FFF;
padding: 0px 20px;
}
.shell-body {
padding: 20px;
border-radius: 10px;
box-shadow: 0px 0px 20px rgba(0, 0, 0, 0.25);
background-color: #FFF;
max-width: 85%;
position: absolute;
top: 80%;
}
body {
margin: 0;
font-family: sans-serif;
}
<div class="shell">
<div class="shell-header"></div>
<div class="shell-body">
<h1>Title</h1>
<p>Lorem ipsum dolor sit amet consectetur adipisicing elit. Placeat vel ducimus illo consectetur commodi ex nulla aut amet ipsum maiores itaque, iusto quam mollitia facilis consequatur tempora neque quod eligendi?</p>
</div>
</div>
<p>Lorem ipsum dolor sit amet consectetur adipisicing elit. Placeat vel ducimus illo consectetur commodi ex nulla aut amet ipsum maiores itaque, iusto quam mollitia facilis consequatur tempora neque quod eligendi?</p>
<p>Lorem ipsum dolor sit amet consectetur adipisicing elit. Placeat vel ducimus illo consectetur commodi ex nulla aut amet ipsum maiores itaque, iusto quam mollitia facilis consequatur tempora neque quod eligendi?</p>
<p>Lorem ipsum dolor sit amet consectetur adipisicing elit. Placeat vel ducimus illo consectetur commodi ex nulla aut amet ipsum maiores itaque, iusto quam mollitia facilis consequatur tempora neque quod eligendi?</p>
I'd create a .wrapper for everything that falls after .shell and add padding-top to the .wrapper.
section {
padding-bottom: 1rem;
position: relative;
}
.shell {
display: flex;
flex-direction: column;
align-items: center;
position: relative;
}
/* overlap */
.shell:before {
content: "";
background-image: url(https://i.ibb.co/x866XdV/test-hero.jpg);
background-repeat: no-repeat;
background-size: cover;
background-position: bottom;
position: relative;
height: 300px;
width: 100%;
}
.shell-header {
color: #FFF;
padding: 0px 20px;
}
.shell-body {
padding: 20px;
border-radius: 10px;
box-shadow: 0px 0px 20px rgba(0, 0, 0, 0.25);
background-color: #FFF;
max-width: 85%;
position: absolute;
top: 80%;
}
body {
margin: 0;
font-family: sans-serif;
}
.wrapper {
padding-top: 9rem;
}
#media only screen and (min-width: 800px) {
.wrapper {
padding-top: 6rem;
}
}
#media only screen and (max-width: 360px) {
.wrapper {
padding-top: 11rem;
}
}
<section>
<div class="shell">
<div class="shell-header"></div>
<div class="shell-body">
<h1>Title</h1>
<p>Lorem ipsum dolor sit amet consectetur adipisicing elit. Placeat vel ducimus illo consectetur commodi ex nulla aut amet ipsum maiores itaque, iusto quam mollitia facilis consequatur tempora neque quod eligendi?</p>
</div>
</div>
<div class="wrapper">
<p>Lorem ipsum dolor sit amet consectetur adipisicing elit. Placeat vel ducimus illo consectetur commodi ex nulla aut amet ipsum maiores itaque, iusto quam mollitia facilis consequatur tempora neque quod eligendi?</p>
<p>Lorem ipsum dolor sit amet consectetur adipisicing elit. Placeat vel ducimus illo consectetur commodi ex nulla aut amet ipsum maiores itaque, iusto quam mollitia facilis consequatur tempora neque quod eligendi?</p>
<p>Lorem ipsum dolor sit amet consectetur adipisicing elit. Placeat vel ducimus illo consectetur commodi ex nulla aut amet ipsum maiores itaque, iusto quam mollitia facilis consequatur tempora neque quod eligendi?</p>
</div>
</section>
Related
I have a card that I'm trying to get the button to go to the bottom of the card to match the card next to it using the equalizer from Foundation. I have the equalizer working on the card's background but have been unsuccessful in getting it to work on the button. I tried doing the nesting solution it gives in their documentation but was unsuccessful. How can I get my button to match the height of other card?
Here is my code:
.grid {
display: grid;
width: 100%;
max-width: 80rem;
margin: 0rem auto;
padding: 1rem;
grid-template-rows: auto;
list-style: none;
grid-template-columns: repeat(2, 1fr);
}
.test-card {
display: flex;
flex-direction: column;
align-items: center;
overflow: visible;
}
.grid-col {
display: block;
grid-row-end: span 1;
grid-column-end: span 1;
position: relative;
}
.test-card-body {
padding: 20px;
background-color: #fff;
max-width: 85%;
margin-top: -6.375rem;
position: relative;
z-index: 1;
}
.container {
/* max-width: 80rem; */
padding: 1rem;
position: relative;
margin-left: auto;
margin-right: auto;
width: 100%;
}
body {
background-color: #efefef;
}
.button {
background-color: grey;
color: white;
border: none;
padding: 5px;
}
<div class="grid" data-equalizer="x0bwi9-equalizer" data-events="mutate" data-mutate="x0bwi9-equalizer" data-resize="x0bwi9-equalizer">
<div class="grid-col test-card"><img alt="" src="https://i.ibb.co/M8TXxQ5/Untitled-1.jpg" />
<div class="test-card-body container" data-equalizer-watch="" style="height: 342px;">
<h2>Text</h2>
<p>Lorem ipsum dolor sit amet consectetur adipisicing elit. Placeat vel ducimus illo consectetur commodi ex nulla aut amet ipsum maiores itaque, iusto quam mollitia facilis consequatur tempora neque quod eligendi? Lorem ipsum dolor sit amet consectetur
adipisicing elit. Placeat vel ducimus illo consectetur commodi ex nulla aut amet ipsum maiores itaque, iusto quam mollitia facilis consequatur tempora neque quod eligendi?</p>
<p>Lorem ipsum dolor sit amet consectetur adipisicing elit. Placeat vel ducimus illo consectetur commodi ex nulla aut amet ipsum maiores itaque, iusto quam mollitia facilis consequatur tempora neque quod eligendi? Lorem ipsum dolor sit amet consectetur
adipisicing elit. Placeat vel ducimus illo consectetur commodi ex nulla aut amet ipsum maiores itaque, iusto quam mollitia facilis consequatur tempora neque quod eligendi?</p>
<div>
<p style="text-align: center;"><button class="button">Button</button></p>
</div>
</div>
</div>
<div class="grid-col test-card"><img alt="" src="https://i.ibb.co/M8TXxQ5/Untitled-1.jpg" />
<div class="test-card-body container" data-equalizer-watch="" style="height: 342px;">
<h2>Text</h2>
<p>Lorem ipsum dolor sit amet consectetur adipisicing elit. Placeat vel ducimus illo consectetur commodi ex nulla aut amet ipsum maiores itaque, iusto quam mollitia facilis consequatur tempora neque quod eligendi?</p>
<div>
<p style="text-align: center;"><button class="button">Button</button></p>
</div>
</div>
</div>
</div>
I am not sure if you are looking for something like this.
.TempClass {
text-align: center;
position: absolute;
bottom: 0px;
left: 50%;
}
I added the above-given css to get the button to go to the bottom of the card
.grid {
display: grid;
width: 100%;
max-width: 80rem;
margin: 0rem auto;
padding: 1rem;
grid-template-rows: auto;
list-style: none;
grid-template-columns: repeat(2, 1fr);
}
.test-card {
display: flex;
flex-direction: column;
align-items: center;
overflow: visible;
}
.grid-col {
display: block;
grid-row-end: span 1;
grid-column-end: span 1;
position: relative;
}
.test-card-body {
padding: 20px;
background-color: #fff;
max-width: 85%;
margin-top: -6.375rem;
position: relative;
z-index: 1;
}
.container {
/* max-width: 80rem; */
padding: 1rem;
position: relative;
margin-left: auto;
margin-right: auto;
width: 100%;
}
body {
background-color: #efefef;
}
.button {
background-color: grey;
color: white;
border: none;
padding: 5px;
}
.TempClass {
text-align: center;
position: absolute;
bottom: 0px;
left: 50%;
}
<div class="grid" data-equalizer="x0bwi9-equalizer" data-events="mutate" data-mutate="x0bwi9-equalizer" data-resize="x0bwi9-equalizer">
<div class="grid-col test-card"><img alt="" src="https://i.ibb.co/M8TXxQ5/Untitled-1.jpg" />
<div class="test-card-body container" data-equalizer-watch="" style="height: 342px;">
<h2>Text</h2>
<p>Lorem ipsum dolor sit amet consectetur adipisicing elit. Placeat vel ducimus illo consectetur commodi ex nulla aut amet ipsum maiores itaque, iusto quam mollitia facilis consequatur tempora neque quod eligendi? Lorem ipsum dolor sit amet consectetur
adipisicing elit. Placeat vel ducimus illo consectetur commodi ex nulla aut amet ipsum maiores itaque, iusto quam mollitia facilis consequatur tempora neque quod eligendi?</p>
<p>Lorem ipsum dolor sit amet consectetur adipisicing elit. Placeat vel ducimus illo consectetur commodi ex nulla aut amet ipsum maiores itaque, iusto quam mollitia facilis consequatur tempora neque quod eligendi? Lorem ipsum dolor sit amet consectetur
adipisicing elit. Placeat vel ducimus illo consectetur commodi ex nulla aut amet ipsum maiores itaque, iusto quam mollitia facilis consequatur tempora neque quod eligendi?</p>
<div>
<p class="TempClass" style="text-align: center;"><button class="button">Button</button></p>
</div>
</div>
</div>
<div class="grid-col test-card"><img alt="" src="https://i.ibb.co/M8TXxQ5/Untitled-1.jpg" />
<div class="test-card-body container" data-equalizer-watch="" style="height: 342px;">
<h2>Text</h2>
<p>Lorem ipsum dolor sit amet consectetur adipisicing elit. Placeat vel ducimus illo consectetur commodi ex nulla aut amet ipsum maiores itaque, iusto quam mollitia facilis consequatur tempora neque quod eligendi?</p>
<div>
<p class="TempClass" style="text-align: center;"><button class="button">Button</button></p>
</div>
</div>
</div>
</div>
Currently my scrollbar is stuck to the border of the div (which has an overflow: "scroll" property) and changing the margin or padding of the scrollbar doesn't do anything. The scrollbar also shouldn't be as tall as the div itself, like 80% of it, but changing the height of it also doesn't work.
Below are pictures of what I'm going for and what it looks like currently and also the CSS styles that are currently on the scrollbar:
.container::-webkit-scrollbar-track {
border-radius: 10px;
background-color: var(--white50);
}
.container::-webkit-scrollbar {
width: 12px;
background-color: transparent;
}
.container::-webkit-scrollbar-thumb {
border-radius: 10px;
background-color: var(--white);
}
You can't move the position of the scrollbar, but you can create an inner container to show the scrollbar in it. So you can have padding you want.
.container {
height: 200px;
width: 300px;
overflow: hidden;
background-color: lightgray;
padding: 20px;
}
.inner-container {
background-color: lightgray;
overflow-y: scroll;
height: 100%;
}
.inner-container::-webkit-scrollbar-track {
border-radius: 10px;
background-color: lightsalmon;
}
.inner-container::-webkit-scrollbar {
width: 12px;
background-color: transparent;
}
.inner-container::-webkit-scrollbar-thumb {
border-radius: 10px;
background-color: white;
}
<div class="container">
<div class="inner-container">
<p>
Lorem ipsum dolor sit amet, consectetur adipisicing elit. Nulla eum minus adipisci, illo eius praesentium ducimus sit amet ipsam. Odio nostrum magni quia maxime quibusdam error facilis laudantium animi quam. Lorem ipsum dolor sit amet, consectetur adipisicing
elit. Nulla eum minus adipisci, illo eius praesentium ducimus sit amet ipsam. Odio nostrum magni quia maxime quibusdam error facilis laudantium animi quam. Lorem ipsum dolor sit amet, consectetur adipisicing elit. Nulla eum minus adipisci, illo
eius praesentium ducimus sit amet ipsam. Odio nostrum magni quia maxime quibusdam error facilis laudantium animi quam. Lorem ipsum dolor sit amet, consectetur adipisicing elit. Nulla eum minus adipisci, illo eius praesentium ducimus sit amet ipsam.
Odio nostrum magni quia maxime quibusdam error facilis laudantium animi quam.
</p>
</div>
</div>
I tried adding min-width property it is also not helping in this case.
My code:
p {
max-width: calc(100% - 500px);
min-width: 10px;
background-color: #333;
color: #fff;
}
<p>Lorem ipsum dolor sit amet consectetur adipisicing elit. Vitae accusantium fuga odio enim, quaerat assumenda in dolorum consequuntur est perspiciatis consectetur temporibus, nulla voluptas ducimus, neque dolorem cum quod autem.</p>
<p>a</p>
Just guessing what you really asked, but here's my answer. I would added
width: fit-content to make div automatically size to content width.
p {
max-width: calc(100% - 100px); /* 500px changed to 100px only to make it fit better in this example snippet */
min-width: 10px;
width: fit-content;
background-color: #333;
color: #fff;
}
<p>Lorem ipsum dolor sit amet consectetur adipisicing elit. Vitae accusantium fuga odio enim, quaerat assumenda in dolorum consequuntur est perspiciatis consectetur temporibus, nulla voluptas ducimus, neque dolorem cum quod autem.</p>
<p>a</p>
Use a container for the <p> tags
.my-class {
max-width: calc(100% - 500px);
min-width: 10px;
width: auto;
display: block;
}
.my-class p {
display: inline-block;
background-color: #333;
color: #fff;
}
<div class='my-class'>
<p>Lorem ipsum dolor sit amet consectetur adipisicing elit. Vitae accusantium fuga odio enim, quaerat assumenda in dolorum consequuntur est perspiciatis consectetur temporibus, nulla voluptas ducimus, neque dolorem cum quod autem.</p>
</div>
<div class='my-class'>
<p>a</p>
</div>
I have a list with text that needs to be cutted off in each item, but when i do
white-space: nowrap;
the item stretches and horizontal scroll bar appears. How to fit cutted text in?
.wrapper {
display: flex;
flex-direction: row;
}
.wrapper-column {
display: flex;
flex-direction: column;
width: 100%;
border: 1px solid #00f;
}
.main-header {
position: sticky;
top: 0;
height: 70px;
border: 1px solid #f0f;
background-color: #fff;
}
.main-content {
height: 1000px;
padding: 15px 25px;
border: 1px solid #000;
}
.sidebar {
position: sticky;
top: 0;
box-sizing: border-box;
flex-shrink: 0;
height: 100vh;
width: 250px;
border: 1px solid #0ff;
}
.content-section {
border: 1px solid #b22222;
}
.content {
padding: 5px;
}
.content-list {
box-sizing: border-box;
display: flex;
flex-direction: row;
padding: 7px 20px;
margin: 0;
height: 40px;
border: 1px solid #3cb371;
list-style: none;
}
.content-list li {
white-space: nowrap;
overflow: hidden;
text-overflow: ellipsis;
min-width:0;
}
<div class="wrapper">
<aside class="sidebar"></aside>
<div class="wrapper-column">
<header class="main-header"></header>
<main class="main-content">
<section class="content-section">
<div class="content">
<ul class="content-list">
<li>Lorem ipsum dolor sit amet consectetur adipisicing elit. Autem libero aspernatur voluptatem, voluptate voluptas enim voluptatibus tempore amet expedita excepturi facere, possimus debitis nam earum!</li>
<li>Lorem ipsum dolor sit amet consectetur, adipisicing elit. Adipisci ratione tempore sint! Suscipit rerum facilis consequuntur, sequi aliquam reiciendis, in quia fugiat nostrum, numquam vel.</li>
<li>Lorem ipsum, dolor sit amet consectetur adipisicing elit. Sit porro facilis numquam culpa illum amet minima, delectus accusantium consectetur cumque repellendus id officia laudantium odio!</li>
</ul>
<ul class="content-list">
<li>Lorem ipsum dolor sit amet consectetur adipisicing elit. Perferendis nam praesentium a hic, molestias ipsam sed nulla, non, quaerat necessitatibus unde. Similique quod illum consequatur.</li>
<li>Lorem ipsum dolor sit amet, consectetur adipisicing elit. Magnam quo adipisci iusto accusantium sed laboriosam officiis placeat eaque veniam animi, facere mollitia repudiandae rerum alias.</li>
<li>Lorem ipsum dolor sit amet consectetur adipisicing elit. In sint, architecto beatae esse culpa deleniti quaerat hic, blanditiis provident natus quam doloribus voluptatibus similique ea!</li>
</ul>
<ul class="content-list">
<li>Lorem ipsum dolor sit amet consectetur adipisicing elit. Culpa tempore laudantium voluptatem dolor quod harum facilis voluptas consectetur minus, nulla, excepturi illum exercitationem eos ipsum!</li>
<li>Lorem ipsum dolor sit amet consectetur adipisicing elit. Cupiditate numquam eveniet debitis, voluptatibus velit, quo aut quos magnam consequatur natus quisquam dicta quidem, illo ipsa.</li>
<li>Lorem ipsum dolor sit, amet consectetur adipisicing elit. Accusantium dolor ipsa, numquam veritatis ut mollitia distinctio. Magnam nobis expedita asperiores dolorum eaque sapiente, tenetur quisquam!</li>
</ul>
</div>
</section>
</main>
</div>
</div>
https://jsfiddle.net/nz7ubw2p/
Instead of using width:100% you should consider flex-grow:1 to fill the remaining space and min-width:0 to disable the auto width and allow the shrink.
.wrapper {
display: flex;
flex-direction: row;
}
.wrapper-column {
display: flex;
flex-direction: column;
flex-grow:1;
min-width:0;
border: 1px solid #00f;
}
.main-header {
position: sticky;
top: 0;
height: 70px;
border: 1px solid #f0f;
background-color: #fff;
}
.main-content {
height: 1000px;
padding: 15px 25px;
border: 1px solid #000;
}
.sidebar {
position: sticky;
top: 0;
box-sizing: border-box;
flex-shrink: 0;
height: 100vh;
width: 250px;
border: 1px solid #0ff;
}
.content-section {
border: 1px solid #b22222;
}
.content {
padding: 5px;
}
.content-list {
box-sizing: border-box;
display: flex;
flex-direction: row;
padding: 7px 20px;
margin: 0;
height: 40px;
border: 1px solid #3cb371;
list-style: none;
}
.content-list li {
white-space: nowrap;
overflow: hidden;
text-overflow: ellipsis;
min-width:0;
}
<div class="wrapper">
<aside class="sidebar"></aside>
<div class="wrapper-column">
<header class="main-header"></header>
<main class="main-content">
<section class="content-section">
<div class="content">
<ul class="content-list">
<li>Lorem ipsum dolor sit amet consectetur adipisicing elit. Autem libero aspernatur voluptatem, voluptate voluptas enim voluptatibus tempore amet expedita excepturi facere, possimus debitis nam earum!</li>
<li>Lorem ipsum dolor sit amet consectetur, adipisicing elit. Adipisci ratione tempore sint! Suscipit rerum facilis consequuntur, sequi aliquam reiciendis, in quia fugiat nostrum, numquam vel.</li>
<li>Lorem ipsum, dolor sit amet consectetur adipisicing elit. Sit porro facilis numquam culpa illum amet minima, delectus accusantium consectetur cumque repellendus id officia laudantium odio!</li>
</ul>
<ul class="content-list">
<li>Lorem ipsum dolor sit amet consectetur adipisicing elit. Perferendis nam praesentium a hic, molestias ipsam sed nulla, non, quaerat necessitatibus unde. Similique quod illum consequatur.</li>
<li>Lorem ipsum dolor sit amet, consectetur adipisicing elit. Magnam quo adipisci iusto accusantium sed laboriosam officiis placeat eaque veniam animi, facere mollitia repudiandae rerum alias.</li>
<li>Lorem ipsum dolor sit amet consectetur adipisicing elit. In sint, architecto beatae esse culpa deleniti quaerat hic, blanditiis provident natus quam doloribus voluptatibus similique ea!</li>
</ul>
<ul class="content-list">
<li>Lorem ipsum dolor sit amet consectetur adipisicing elit. Culpa tempore laudantium voluptatem dolor quod harum facilis voluptas consectetur minus, nulla, excepturi illum exercitationem eos ipsum!</li>
<li>Lorem ipsum dolor sit amet consectetur adipisicing elit. Cupiditate numquam eveniet debitis, voluptatibus velit, quo aut quos magnam consequatur natus quisquam dicta quidem, illo ipsa.</li>
<li>Lorem ipsum dolor sit, amet consectetur adipisicing elit. Accusantium dolor ipsa, numquam veritatis ut mollitia distinctio. Magnam nobis expedita asperiores dolorum eaque sapiente, tenetur quisquam!</li>
</ul>
</div>
</section>
</main>
</div>
</div>
With standard behavior of overflow: scroll the padding-bottom is in the bottom of the scrolled block. But how can I make padding-bottom fixed, so odd text will not appear right after bottom border
https://jsfiddle.net/nvg23rp8/6/
body{
background-color: green;
}
.wrapper{
height: 100px;
width: 300px;
background: transparent;
border: 1px solid #000;
padding-top: 20px;
padding-bottom: 20px;
overflow-y: scroll;
position: fixed;
left: 10%;
top: 10%;
}
.middle{
padding-left: 20px;
padding-right: 20px;
height: 100%;
}
.inner{
background: blue;
height: 100%;
}
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script>
<div class="wrapper">
<div class="middle">
<div class="inner">
Lorem ipsum dolor sit amet, consectetur adipisicing elit. Modi, atque asperiores incidunt aspernatur libero commodi? Quas aspernatur ducimus minima rerum eum veniam, tempora, numquam, fugiat veritatis ea, nemo error totam.
Lorem ipsum dolor sit amet, consectetur adipisicing elit. Sed perspiciatis, nam nulla optio repellendus ratione, at! Ut reiciendis, laboriosam a in soluta odit impedit, quia magnam esse, maxime autem suscipit.
</div>
</div>
</div>
CSS is all about illusions!
Make an outer container and give it some padding to give the required illusion. I couldn't get your Fiddle, so I made a new one. Here you go: https://jsfiddle.net/z9ztcstb/
.container {
position: relative;
}
.text-container {
background: red;
padding: 10px;
}
.text {
height: 100px;
/* background: green; */
overflow: scroll;
}
<div class="container">
<div class="text-container">
<div class="text">
Lorem ipsum dolor sit amet, consectetur adipisicing elit. In
quae earum recusandae beatae, optio. Incidunt velit corporis nesciunt, soluta dolor laborum eius recusandae perspiciatis. Est alias minima hic iure, incidunt! Lorem ipsum dolor sit amet, consectetur adipisicing elit. Veniam alias suscipit, quia, vitae consectetur laudantium nisi itaque odio aliquam dolorem voluptas atque, eos perspiciatis. Excepturi cumque doloribus ad, itaque tempore.Lorem ipsum dolor sit amet, consectetur adipisicing elit. Error quaerat saepe possimus fuga consequuntur, dolorum facere harum, ullam id similique tempora magni non dolores. Praesentium esse omnis quia eaque quos!
</div>
</div>
</div>
I would suggest that you put the scroll on the inner box, this would be the most effective way of preventing unwanted overflow of text below the blue background. You could do this without the 'inner' css. Try this out. fiddle here
Hope this helps
$('.wrapper').on('scroll', function() {
$('.inner').scrollTop($(this).scrollTop());
});
body {
background-color: green;
}
.wrapper {
height: 100px;
width: 300px;
background: transparent;
border: 1px solid #000;
padding-bottom: 30px;
position: fixed;
left: 10%;
top: 10%;
}
.middle {
margin: 20px;
padding: 2px 5px;
height: 90%;
overflow-y: scroll;
background: blue;
}
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script>
<div class="wrapper">
<div class="middle">
Lorem ipsum dolor sit amet, consectetur adipisicing elit. Modi, atque asperiores incidunt aspernatur libero commodi? Quas aspernatur ducimus minima rerum eum veniam, tempora, numquam, fugiat veritatis ea, nemo error totam. Lorem ipsum dolor sit amet,
consectetur adipisicing elit. Sed perspiciatis, nam nulla optio repellendus ratione, at! Ut reiciendis, laboriosam a in soluta odit impedit, quia magnam esse, maxime autem suscipit.
</div>
</div>
this will work:
<div class="wrapper">
<div class="content">
Lorem ipsum dolor sit amet, consectetur adipisicing elit. Modi, atque asperiores incidunt aspernatur libero commodi? Quas aspernatur ducimus minima rerum eum veniam, tempora, numquam, fugiat veritatis ea, nemo error totam.
Lorem ipsum dolor sit amet, consectetur adipisicing elit. Sed perspiciatis, nam nulla optio repellendus ratione, at! Ut reiciendis, laboriosam a in soluta odit impedit, quia magnam esse, maxime autem suscipit.Lorem ipsum dolor sit amet, consectetur adipisicing elit. Modi, atque asperiores incidunt aspernatur libero commodi? Quas aspernatur ducimus minima rerum eum veniam, tempora, numquam, fugiat veritatis ea, nemo error totam.
</div>
<div class="border">
</div>
</div>
div.wrapper {
width:340px;
height:120px;
background-color:#ccc;
overflow:auto;
position:relative;
}
div.border {
border:solid 10px red;
height:100px;
position:fixed;
width:300px;
height:100px;
top:0;
left:0;
}
div.content{
z-index:1;
margin:10px;
}
The main point is to put the border outside of the .wrapper container.
The only issue I can see here is you cannot use mouse wheel to scroll .content inside .wrapper, since it has been overlapped by .border
Here is a JSFiddle link you can see: https://jsfiddle.net/zsydyc/pw9jz5s2/3/
I think this might be helpful.
body{
background-color: green;
}
.wrapper{
height: 140px;
width: 300px;
background: transparent;
border: 1px solid #000;
position: fixed;
left: 10%;
top: 10%;
}
.middle{
padding-top: 20px;
padding-bottom: 20px;
padding-left: 20px;
padding-right: 20px;
height: 100px;
}
.inner{
background: blue;
overflow-y: scroll;
height: 100%;
}
::-webkit-scrollbar {
width: .5rem;
background: inherit;
}
::-webkit-scrollbar-thumb {
background: #f00;
border-radius:.5rem;
}
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script>
<div class="wrapper">
<div class="middle">
<div class="inner">
Lorem ipsum dolor sit amet, consectetur adipisicing elit. Modi, atque asperiores incidunt aspernatur libero commodi? Quas aspernatur ducimus minima rerum eum veniam, tempora, numquam, fugiat veritatis ea, nemo error totam.
Lorem ipsum dolor sit amet, consectetur adipisicing elit. Sed perspiciatis, nam nulla optio repellendus ratione, at! Ut reiciendis, laboriosam a in soluta odit impedit, quia magnam esse, maxime autem suscipit.
</div>
</div>
</div>