parent's relative position grows to fit the child absolute position height - html

How can I set the height of a parent (relative position) to height of the it's children?
Take a look at this pen to see it in action.
blockquote {
position: relative;
width: 100%;
height: auto;
margin: 0 auto;
color: #edf0f9;
overflow: hidden;
}
blockquote img {
width: 5.5rem;
height: 5.5rem;
border-radius: 50%;
position: absolute;
top: 0;
right: 1rem;
z-index: 2;
}
blockquote .name-block {
padding: 0.1rem 2rem 0.1rem 0.5rem;
background-color: #6e7480;
font-size: 0.8rem;
position: absolute;
top: 2rem;
right: 5rem;
z-index: 1;
}
blockquote .pos-block {
padding: 0.1rem 3rem 0.1rem 0.5rem;
background-color: #6e7480;
font-size: 0.8rem;
position: absolute;
top: 3.6rem;
right: 4rem;
z-index: 1;
}
blockquote .txt-block {
background-color: #2b2d32;
padding: 5rem 1rem 1rem 1.8rem;
position: absolute;
top: 1.5rem;
right: 0;
}
blockquote .txt-block:before {
content: '';
position: absolute;
left: 1rem;
top: 4.5rem;
border-left: 2px solid #6e7480;
height: calc(100% - 5rem);
}
<blockquote>
<img src="http://7108-presscdn-0-78.pagely.netdna-cdn.com/wp-content/uploads/2013/09/person-to-person-business.jpg" />
<span class="name-block">John Doe</span>
<span class="pos-block">A mannager</span>
<div class="txt-block">Lorem ipsum dolor sit amet, consectetur adipisicing elit. Voluptate iste ipsam facere reprehenderit iure odio voluptatem quod voluptatibus natus officiis. Consequatur eius architecto deleniti beatae sapiente laboriosam tempora, deserunt officia asperiores
incidunt ea accusantium debitis blanditiis nesciunt ex minus ipsam nobis unde in distinctio, vero alias magni dolorum dolore? Debitis non aspernatur quis minus laboriosam. Voluptates maxime consequatur doloremque accusantium esse aperiam, voluptate
voluptas officiis perspiciatis, minus sed ab voluptatum nisi cumque sapiente illo culpa a magnam ducimus omnis animi cum dignissimos? Vero quaerat quisquam ipsam libero porro nulla fugit repellat, accusantium, quidem, laudantium perspiciatis cupiditate
vel dolore aliquid sapiente rem dolorem voluptatem architecto minus facilis eos expedita alias nesciunt dolores. Eum eos architecto, eveniet illo, sit doloribus, debitis possimus non placeat quibusdam odio quidem ab dicta dolorum blanditiis accusamus.
Perferendis veniam officiis rem, ex iusto nesciunt! Sit incidunt saepe ab velit, adipisci totam rerum nostrum fugit, architecto deserunt ea!
</div>
</blockquote>
I set the blockquote element position to relative and set the child of its to absolute and when the the overflow of the parent set to hidden the height of blockquote automatically set to 0 and the content just show when overflow: visible or height strictly set.

When you position an element absolute, it is taken out of the normal flow and so blockquote (which is your parent relative element) will have zero height.
Now if if you use overflow: hidden on blockquote, it will hide everything.
So the best option is to put something on the normal flow and that would be txt-block - remove absolute positioning and give a margin-top to get the desired effect - see demo below:
blockquote {
position: relative;
width: 100%;
height: auto;
margin: 0 auto;
color: #edf0f9;
overflow: hidden;
}
blockquote img {
width: 5.5rem;
height: 5.5rem;
border-radius: 50%;
position: absolute;
top: 0;
right: 1rem;
z-index: 2;
}
blockquote .name-block {
padding: 0.1rem 2rem 0.1rem 0.5rem;
background-color: #6e7480;
font-size: 0.8rem;
position: absolute;
top: 2rem;
right: 5rem;
z-index: 1;
}
blockquote .pos-block {
padding: 0.1rem 3rem 0.1rem 0.5rem;
background-color: #6e7480;
font-size: 0.8rem;
position: absolute;
top: 3.6rem;
right: 4rem;
z-index: 1;
}
blockquote .txt-block {
background-color: #2b2d32;
padding: 5rem 1rem 1rem 1.8rem;
margin-top: 1.5rem;
}
blockquote .txt-block:before {
content: '';
position: absolute;
left: 1rem;
top: 4.5rem;
border-left: 1px solid #6e7480;
height: calc(100% - 5rem);
}
<blockquote>
<img src="http://7108-presscdn-0-78.pagely.netdna-cdn.com/wp-content/uploads/2013/09/person-to-person-business.jpg" />
<span class="name-block">John Doe</span>
<span class="pos-block">A mannager</span>
<div class="txt-block">Lorem ipsum dolor sit amet, consectetur adipisicing elit. Voluptate iste ipsam facere reprehenderit iure odio voluptatem quod voluptatibus natus officiis. Consequatur eius architecto deleniti beatae sapiente laboriosam tempora, deserunt officia asperiores
incidunt ea accusantium debitis blanditiis nesciunt ex minus ipsam nobis unde in distinctio, vero alias magni dolorum dolore? Debitis non aspernatur quis minus laboriosam. Voluptates maxime consequatur doloremque accusantium esse aperiam, voluptate
voluptas officiis perspiciatis, minus sed ab voluptatum nisi cumque sapiente illo culpa a magnam ducimus omnis animi cum dignissimos? Vero quaerat quisquam ipsam libero porro nulla fugit repellat, accusantium, quidem, laudantium perspiciatis cupiditate
vel dolore aliquid sapiente rem dolorem voluptatem architecto minus facilis eos expedita alias nesciunt dolores. Eum eos architecto, eveniet illo, sit doloribus, debitis possimus non placeat quibusdam odio quidem ab dicta dolorum blanditiis accusamus.
Perferendis veniam officiis rem, ex iusto nesciunt! Sit incidunt saepe ab velit, adipisci totam rerum nostrum fugit, architecto deserunt ea!
</div>
</blockquote>
Let me know your thoughts on this, thanks!

You have set the min-height or height.
blockquote {
position: relative;
width: 100%;
height: auto;
margin: 0 auto;
color: #edf0f9;
overflow: hidden;
min-height: 100px;
}
http://codepen.io/hemedani/pen/vyNXJL

Related

CSS Smooth scrolling property not working

I know it's a question asked by many people but after dozens of posts I still cannot figure out the answer to this.
I have a simple html page:
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>JEFDocs | All Docs | Template</title>
<link rel="stylesheet" href="css/main.css">
<link rel="stylesheet" href="css/module.css">
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/highlight.js/10.0.3/styles/default.min.css">
<script src="https://cdnjs.cloudflare.com/ajax/libs/highlight.js/10.0.3/highlight.min.js"></script>
<script>hljs.initHighlightingOnLoad();</script>
</head>
<body>
<div class="navbar">
<div class="container">
<a class="logo" href="index.html">JEF<span>Docs</span></a>
<img id="mobile-cta" class="mobile-menu" src="images/menu.svg" alt="Open Navigation">
<nav>
<img id="mobile-exit" class="mobile-menu-exit" src="images/exit.svg" alt="Close Navigation">
<ul class="primary-nav">
<li class="current">All Docs</li>
<li>GitHub</li>
<li>About</li>
</ul>
</nav>
</div>
</div>
<div class="docs-content">
<div class="left-space">
<p>In this page</p>
<ul class="left-nav">
<li>Item1</li>
<li>Item2</li>
</ul>
</div>
<div class="right-space">
<!-------------------------------------------------------------------------------------------------------------------------------->
<h1 id="1">Main Title</h1>
<h3>Subtitle</h3>
<p>
Paragraph
With code:
<pre><code class="pyton">print("Hello world")
x=10
print(x)</code></pre>
Lorem ipsum dolor sit amet, consectetur adipisicing elit. Cum saepe expedita commodi consectetur ipsum. Deleniti delectus, quas voluptatibus eum dolore accusamus aliquid voluptate a error sunt dolores mollitia. At, mollitia.
A nulla eligendi provident exercitationem! Minus perspiciatis eum vel similique, ducimus illum qui sint magnam, asperiores adipisci nesciunt in, rem assumenda repellendus! Blanditiis corporis, quidem dolore expedita consectetur aliquid eius!
Similique, provident illo nihil, unde iure perspiciatis corrupti, eius ad sint consequuntur asperiores error harum? Laborum beatae in dolorem ullam itaque quos deleniti quae debitis, magnam autem ipsa deserunt? Illo!
Nesciunt perspiciatis a corporis necessitatibus sed asperiores voluptas error saepe tempora rem voluptatibus quae ipsa molestias soluta nostrum, non sunt accusamus fuga numquam ut illo dicta! Deleniti magni doloribus ea.
Odio, quas fugiat harum eos animi suscipit dolorum ipsam aliquid perspiciatis, vitae quam assumenda soluta voluptas delectus? Placeat, repellat. Voluptatibus sint blanditiis explicabo similique, exercitationem et tempora consequatur ex asperiores!
Animi vel dignissimos inventore eligendi quisquam alias vitae earum itaque neque fugiat rem amet culpa atque delectus quod, tenetur praesentium in autem porro quam qui reprehenderit! Corrupti soluta qui illum.
Ut at sint, eius aperiam vitae, magni vel harum distinctio excepturi iusto laborum itaque deserunt cumque eaque. Qui ex quas blanditiis repellat, temporibus ab inventore perferendis sapiente cum quo laborum?
Sunt tempora possimus culpa odit numquam, nobis commodi quod, vero repellat autem nostrum laboriosam. Consequuntur hic excepturi in amet unde voluptatibus a? Optio officia obcaecati voluptatem quod dolores minus doloribus?
Nihil alias nesciunt veniam modi similique blanditiis officiis, ratione obcaecati dolores aliquid quos iusto ducimus excepturi voluptas expedita, laboriosam corrupti illum quibusdam doloribus quaerat? Quaerat neque quia impedit atque vel.
Veritatis placeat officia maiores inventore laborum illo enim vitae, ratione, dolorem esse est! Omnis, libero facere eaque vitae fuga ullam cumque consequatur porro ab recusandae, soluta facilis? Quasi, rem voluptate?
Soluta eius molestiae nemo, maiores dolore ratione placeat! Esse, doloribus tempora sint sed rem reiciendis corrupti. Sit mollitia veniam tempora iusto ipsa voluptate quod, eaque veritatis quasi iste hic quas!
Corporis pariatur, esse ipsum labore alias accusamus voluptatem veritatis ipsa possimus deserunt veniam deleniti facilis aliquam magni quidem, eligendi tempore ab dicta amet optio nesciunt provident voluptas eaque? Inventore, ducimus.
Numquam, deserunt voluptatibus veritatis est omnis ducimus ab tempora cupiditate fuga deleniti officiis velit molestiae facilis eveniet debitis, reprehenderit iure repellendus impedit animi dolorum culpa nostrum rerum illo! Quidem, soluta.
Corrupti sapiente eius necessitatibus nostrum incidunt, modi, in quae accusantium totam minima ducimus, aperiam nulla velit eos. Adipisci dignissimos eveniet, quia, voluptatibus unde repellat aperiam doloremque mollitia fugiat minus dolor.
Maxime sequi pariatur, quod, esse animi placeat quibusdam excepturi doloremque consectetur culpa commodi enim. Autem voluptas quasi excepturi natus laborum quas ad voluptatibus adipisci repellendus quia, ratione minus cupiditate itaque.
Voluptate repellendus id molestiae ipsam impedit aspernatur facere magni. Eveniet aut praesentium officiis ea fugit tenetur pariatur, veritatis deserunt! Beatae, vero odit. Aliquam delectus ipsam maxime repellat tenetur, doloribus iure.
Aspernatur vel suscipit sequi enim recusandae ratione perspiciatis, facere, fugiat incidunt, error iusto quibusdam consectetur eos. Quasi vel neque aperiam aliquid rerum, facilis cupiditate deleniti voluptate modi, nihil sunt distinctio.
</p>
<h1 id="2">Second Title</h1>
<p>
Id totam deleniti sit, magni praesentium velit voluptatum, molestias, recusandae nulla ratione quae blanditiis numquam! Sapiente nam unde quidem. Id dolor libero ipsam dolore incidunt corrupti omnis dolorem! Tempora, impedit?
Officia at cum libero unde ipsa veritatis obcaecati est quod delectus sequi voluptatem veniam consequatur sit nobis eveniet eos ab dolore earum vero, molestias nam! Ducimus optio harum necessitatibus debitis.
Dignissimos quo aspernatur iste, itaque vel voluptates fugiat dolorem maiores assumenda repellat accusamus, illo praesentium tempora aliquid sed doloribus provident, optio quia nihil. Consectetur optio quisquam eum deserunt nostrum delectus.
At libero odio suscipit quae veniam possimus dolores eum praesentium aliquid illo, voluptates similique, dignissimos, magni alias debitis harum nemo. Officia, vel! Quis minima, nesciunt eos ipsum rem quos sed!
Ad possimus error, iste facere aut voluptatem odit, voluptatum ea eos fugiat, quas cupiditate? Dolores architecto doloribus repudiandae necessitatibus repellendus officia tenetur perspiciatis, modi fugiat aliquam, tempora unde maiores doloremque.
A, nam id et adipisci nostrum natus eligendi ducimus est quos sed eveniet? Nobis saepe placeat optio natus, atque est eius nesciunt, quaerat deleniti velit consequatur laborum molestiae error dolore?
Ducimus, quam nostrum ipsam ex dolores maxime impedit corrupti deserunt dolor quod similique. Sed nihil explicabo laudantium a aut provident, ex pariatur aspernatur minus cupiditate saepe accusamus, expedita impedit iste!
Vero vel iure, quaerat unde dolore tempora molestias eum facilis cumque consequuntur non totam aperiam cum voluptas qui nihil incidunt fugiat aliquid! Ipsum accusantium vero quod, fugiat soluta illum recusandae.
Facere veniam ut est, tempora suscipit temporibus esse exercitationem reiciendis ipsam eaque dolorum, maiores dolorem ducimus voluptatem accusantium. Dicta dolorem reiciendis rerum explicabo sint pariatur illum tenetur. Laborum, tenetur repellat!
Inventore, optio quas necessitatibus consectetur atque temporibus porro dolorem dicta incidunt eaque et unde animi! Rem eaque unde placeat accusantium repudiandae blanditiis, quod voluptate natus fuga, nisi sit adipisci totam?
Explicabo consequuntur tempore dignissimos, debitis odit mollitia incidunt atque animi esse facere, ipsa ducimus repellendus deserunt laboriosam aliquam. Autem repudiandae voluptate dicta, reiciendis quos iusto voluptates ipsum rem iure incidunt!
</p>
<!-------------------------------------------------------------------------------------------------------------------------------->
</div>
</div>
<script>
const mobileBtn = document.getElementById('mobile-cta')
nav = document.querySelector('nav')
mobileBtnExit = document.getElementById('mobile-exit')
ul = document.querySelector('ul')
menuArrow = document.getElementById('menu-arrow');
mobileBtn.addEventListener('click', () => {
nav.classList.add('menu-btn')
})
mobileBtnExit.addEventListener('click', () => {
nav.classList.remove('menu-btn')
})
function scrollToTop() {
window.scrollTo({
behavior: 'smooth'
});
}
</script>
</body>
</html>
And a css file:
#import url("https://fonts.googleapis.com/css2?family=Poppins:wght#400;700&display=swap");
:root {
--primary-color: #3272B8;
--secondary-color: #132F47;
}
::-webkit-scrollbar {
width: 9px;
height: 5px;
}
::-webkit-scrollbar-track {
background: #f1f1f1;
}
::-webkit-scrollbar-thumb {
background: var(--secondary-color);
}
::-webkit-scrollbar-thumb:hover {
background: var(--primary-color);
}
html {
scroll-behavior: smooth;
}
.docs-content .left-space {
margin: 1em auto;
width: 90%;
padding: .5em;
background: var(--secondary-color);
-webkit-box-shadow: 4px 4px 15px rgba(0, 0, 0, 0.514);
box-shadow: 4px 4px 15px rgba(0, 0, 0, 0.514);
-webkit-animation: transitionIn 1s;
animation: transitionIn 1s;
}
.docs-content .left-space .left-nav {
font-size: 1.1em;
display: -ms-grid;
display: grid;
-ms-grid-columns: auto auto;
grid-template-columns: auto auto;
}
.docs-content .left-space p {
margin-left: .7em;
font-weight: bold;
font-size: 1.3em;
color: white;
}
.docs-content .left-space a {
color: white;
display: block;
text-decoration: none;
font-size: .8em;
padding: .5em 1em;
}
.docs-content .left-space a:hover {
color: var(--primary-color);
}
#-webkit-keyframes transitionRight {
from {
-webkit-transform: translateX(90px);
transform: translateX(90px);
opacity: 0;
}
to {
-webkit-transform: translateX(0);
transform: translateX(0);
opacity: 1;
}
}
#keyframes transitionRight {
from {
-webkit-transform: translateX(90px);
transform: translateX(90px);
opacity: 0;
}
to {
-webkit-transform: translateX(0);
transform: translateX(0);
opacity: 1;
}
}
.docs-content .right-space {
margin: 2em auto;
width: 90%;
background: white;
overflow-y: scroll;
padding: 1em;
height: 100vh;
-webkit-box-shadow: 4px 4px 15px rgba(0, 0, 0, 0.514);
box-shadow: 4px 4px 15px rgba(0, 0, 0, 0.514);
-webkit-animation: transitionRight 1s;
animation: transitionRight 1s;
}
.docs-content .right-space h1 {
margin: 0;
padding: 0;
color: var(--primary-color);
}
#media only screen and (min-width: 768px) {
.docs-content .right-space {
padding: 1em;
overflow-y: scroll;
}
}
#media only screen and (min-width: 1080px) {
.docs-content {
margin: 3em auto;
width: 1080px;
display: -webkit-box;
display: -ms-flexbox;
display: flex;
}
.docs-content .left-space {
height: 65.9vh;
width: 33%;
margin-top: 0;
background: var(--secondary-color);
margin-right: 2em;
-webkit-box-shadow: 4px 4px 15px rgba(0, 0, 0, 0.514);
box-shadow: 4px 4px 15px rgba(0, 0, 0, 0.514);
padding: 2em;
}
.docs-content .left-space p {
color: white;
font-size: 1.5em;
margin-top: 0;
margin-left: .3em;
}
.docs-content .left-space .left-nav {
border: none;
display: block;
}
.docs-content .left-space .left-nav a {
color: white;
font-size: 1em;
font-weight: 400;
}
.docs-content .left-space .left-nav a:hover {
color: var(--primary-color);
font-weight: bold;
}
.docs-content .right-space {
margin-top: 0;
height: 70vh;
width: 66%;
overflow-y: scroll;
background: white;
-webkit-box-shadow: 4px 4px 15px rgba(0, 0, 0, 0.514);
box-shadow: 4px 4px 15px rgba(0, 0, 0, 0.514);
}
.right-space::-webkit-scrollbar {
width: 12px;
}
.right-space::-webkit-scrollbar-track {
background: #f1f1f1;
}
.right-space::-webkit-scrollbar-thumb {
background: var(--secondary-color);
}
.right-space::-webkit-scrollbar-thumb:hover {
background: var(--primary-color);
}
}
/*# sourceMappingURL=module.css.map */
The problem I'm facing is that the html{scroll-behavior: smooth;} is not working at all.
I am also going to include the "main.css" (used to style the navbar at the top) file so that everybody can run this and help me:
#import url("https://fonts.googleapis.com/css2?family=Poppins:wght#400;700&display=swap");
#-webkit-keyframes opacityIn {
from {
opacity: 0;
}
to {
opacity: 1;
}
}
#keyframes opacityIn {
from {
opacity: 0;
}
to {
opacity: 1;
}
}
#-webkit-keyframes transitionIn {
from {
-webkit-transform: translateX(-90px);
transform: translateX(-90px);
opacity: 0;
}
to {
-webkit-transform: translateX(0);
transform: translateX(0);
opacity: 1;
}
}
#keyframes transitionIn {
from {
-webkit-transform: translateX(-90px);
transform: translateX(-90px);
opacity: 0;
}
to {
-webkit-transform: translateX(0);
transform: translateX(0);
opacity: 1;
}
}
:root {
--primary-color: #3272B8;
}
body {
background: #f2f2f2f2;
margin: 0;
font-family: 'Poppins';
}
a {
color: white;
}
ul {
list-style-type: none;
margin: 0;
padding: 0;
}
.navbar {
background: white;
padding: 1em;
}
.navbar .logo {
text-decoration: none;
font-weight: bold;
color: black;
font-size: 1.2em;
}
.navbar .logo span {
color: var(--primary-color);
}
.navbar nav {
display: none;
}
.navbar .container {
display: -webkit-box;
display: -ms-flexbox;
display: flex;
-webkit-box-pack: justify;
-ms-flex-pack: justify;
justify-content: space-between;
}
.navbar .mobile-menu {
cursor: pointer;
}
.hero {
text-align: center;
margin-top: 3em;
}
.left-col h1 {
font-size: 2.5em;
line-height: 1.3em;
margin-top: .2em;
-webkit-animation: transitionIn 1s;
animation: transitionIn 1s;
}
.left-col .primary-cta {
background: var(--primary-color);
color: white;
border: 3px var(--primary-color) solid;
text-decoration: none;
padding: .6em 1.3em;
font-size: 1.4em;
border-radius: 5em;
font-weight: bold;
display: inline-block;
-webkit-transition: all 300ms ease;
transition: all 300ms ease;
}
.left-col .primary-cta:hover, .left-col .primary-cta:focus {
background-color: #F2F2F2F2;
color: var(--primary-color);
border: 3px var(--primary-color) solid;
}
.hero-img {
width: 70%;
margin-top: 3em;
-webkit-animation: opacityIn 3s;
animation: opacityIn 3s;
}
nav.menu-btn {
display: block;
}
nav {
position: fixed;
z-index: 999;
width: 66%;
right: 0;
top: 0;
background: #20272E;
height: 100vh;
padding: 1em;
}
nav ul.primary-nav {
margin-top: 5em;
}
nav li a {
color: white;
text-decoration: none;
display: block;
padding: .5em;
font-size: 1.3em;
text-align: right;
}
nav li a:hover {
color: var(--primary-color);
font-weight: bold;
}
.mobile-menu-exit {
float: right;
margin: .5em;
cursor: pointer;
}
#media only screen and (min-width: 768px) {
.mobile-menu, .mobile-menu-exit {
display: none;
}
.navbar .container {
display: -ms-grid;
display: grid;
-ms-grid-columns: 180px auto;
grid-template-columns: 180px auto;
}
.navbar nav {
display: -webkit-box;
display: -ms-flexbox;
display: flex;
-webkit-box-pack: justify;
-ms-flex-pack: justify;
justify-content: space-between;
background: none;
position: unset;
height: auto;
width: 100%;
padding: 0;
}
.navbar nav ul {
display: -webkit-box;
display: -ms-flexbox;
display: flex;
}
.navbar nav a {
color: black;
font-size: 1em;
padding: .1em 1em;
}
.navbar nav ul.primary-nav {
margin: 0;
}
.hero-img {
width: 30%;
margin-top: 6em;
}
}
#media only screen and (min-width: 1080px) {
.container {
width: 1080px;
margin: 0 auto;
}
section {
padding: 4em 4em;
}
.hero .container {
display: -webkit-box;
display: -ms-flexbox;
display: flex;
-webkit-box-pack: justify;
-ms-flex-pack: justify;
justify-content: space-between;
text-align: left;
}
.hero .container .left-col {
margin: 0 3em 0 5em;
}
.hero .container .left-col h1 {
font-size: 3em;
width: 90%;
}
.hero-img {
width: 30%;
margin-right: 8em;
}
.hero-cta {
margin-left: 2em;
}
}
/*# sourceMappingURL=main.css.map */
const mobileBtn = document.getElementById('mobile-cta')
nav = document.querySelector('nav')
mobileBtnExit = document.getElementById('mobile-exit')
ul = document.querySelector('ul')
menuArrow = document.getElementById('menu-arrow');
mobileBtn.addEventListener('click', () => {
nav.classList.add('menu-btn')
})
mobileBtnExit.addEventListener('click', () => {
nav.classList.remove('menu-btn')
})
function scrollToTop() {
window.scrollTo({
behavior: 'smooth'
});
}
#import url("https://fonts.googleapis.com/css2?family=Poppins:wght#400;700&display=swap");
:root {
--primary-color: #3272B8;
--secondary-color: #132F47;
}
::-webkit-scrollbar {
width: 9px;
height: 5px;
}
::-webkit-scrollbar-track {
background: #f1f1f1;
}
::-webkit-scrollbar-thumb {
background: var(--secondary-color);
}
::-webkit-scrollbar-thumb:hover {
background: var(--primary-color);
}
html {
scroll-behavior: smooth;
}
.docs-content .left-space {
margin: 1em auto;
width: 90%;
padding: .5em;
background: var(--secondary-color);
-webkit-box-shadow: 4px 4px 15px rgba(0, 0, 0, 0.514);
box-shadow: 4px 4px 15px rgba(0, 0, 0, 0.514);
-webkit-animation: transitionIn 1s;
animation: transitionIn 1s;
}
.docs-content .left-space .left-nav {
font-size: 1.1em;
display: -ms-grid;
display: grid;
-ms-grid-columns: auto auto;
grid-template-columns: auto auto;
}
.docs-content .left-space p {
margin-left: .7em;
font-weight: bold;
font-size: 1.3em;
color: white;
}
.docs-content .left-space a {
color: white;
display: block;
text-decoration: none;
font-size: .8em;
padding: .5em 1em;
}
.docs-content .left-space a:hover {
color: var(--primary-color);
}
#-webkit-keyframes transitionRight {
from {
-webkit-transform: translateX(90px);
transform: translateX(90px);
opacity: 0;
}
to {
-webkit-transform: translateX(0);
transform: translateX(0);
opacity: 1;
}
}
#keyframes transitionRight {
from {
-webkit-transform: translateX(90px);
transform: translateX(90px);
opacity: 0;
}
to {
-webkit-transform: translateX(0);
transform: translateX(0);
opacity: 1;
}
}
.docs-content .right-space {
margin: 2em auto;
width: 90%;
background: white;
overflow-y: scroll;
padding: 1em;
height: 100vh;
-webkit-box-shadow: 4px 4px 15px rgba(0, 0, 0, 0.514);
box-shadow: 4px 4px 15px rgba(0, 0, 0, 0.514);
-webkit-animation: transitionRight 1s;
animation: transitionRight 1s;
}
.docs-content .right-space h1 {
margin: 0;
padding: 0;
color: var(--primary-color);
}
#media only screen and (min-width: 768px) {
.docs-content .right-space {
padding: 1em;
overflow-y: scroll;
}
}
#media only screen and (min-width: 1080px) {
.docs-content {
margin: 3em auto;
width: 1080px;
display: -webkit-box;
display: -ms-flexbox;
display: flex;
}
.docs-content .left-space {
height: 65.9vh;
width: 33%;
margin-top: 0;
background: var(--secondary-color);
margin-right: 2em;
-webkit-box-shadow: 4px 4px 15px rgba(0, 0, 0, 0.514);
box-shadow: 4px 4px 15px rgba(0, 0, 0, 0.514);
padding: 2em;
}
.docs-content .left-space p {
color: white;
font-size: 1.5em;
margin-top: 0;
margin-left: .3em;
}
.docs-content .left-space .left-nav {
border: none;
display: block;
}
.docs-content .left-space .left-nav a {
color: white;
font-size: 1em;
font-weight: 400;
}
.docs-content .left-space .left-nav a:hover {
color: var(--primary-color);
font-weight: bold;
}
.docs-content .right-space {
margin-top: 0;
height: 70vh;
width: 66%;
overflow-y: scroll;
background: white;
-webkit-box-shadow: 4px 4px 15px rgba(0, 0, 0, 0.514);
box-shadow: 4px 4px 15px rgba(0, 0, 0, 0.514);
}
.right-space::-webkit-scrollbar {
width: 12px;
}
.right-space::-webkit-scrollbar-track {
background: #f1f1f1;
}
.right-space::-webkit-scrollbar-thumb {
background: var(--secondary-color);
}
.right-space::-webkit-scrollbar-thumb:hover {
background: var(--primary-color);
}
}
#import url("https://fonts.googleapis.com/css2?family=Poppins:wght#400;700&display=swap");
#-webkit-keyframes opacityIn {
from {
opacity: 0;
}
to {
opacity: 1;
}
}
#keyframes opacityIn {
from {
opacity: 0;
}
to {
opacity: 1;
}
}
#-webkit-keyframes transitionIn {
from {
-webkit-transform: translateX(-90px);
transform: translateX(-90px);
opacity: 0;
}
to {
-webkit-transform: translateX(0);
transform: translateX(0);
opacity: 1;
}
}
#keyframes transitionIn {
from {
-webkit-transform: translateX(-90px);
transform: translateX(-90px);
opacity: 0;
}
to {
-webkit-transform: translateX(0);
transform: translateX(0);
opacity: 1;
}
}
:root {
--primary-color: #3272B8;
}
body {
background: #f2f2f2f2;
margin: 0;
font-family: 'Poppins';
}
a {
color: white;
}
ul {
list-style-type: none;
margin: 0;
padding: 0;
}
.navbar {
background: white;
padding: 1em;
}
.navbar .logo {
text-decoration: none;
font-weight: bold;
color: black;
font-size: 1.2em;
}
.navbar .logo span {
color: var(--primary-color);
}
.navbar nav {
display: none;
}
.navbar .container {
display: -webkit-box;
display: -ms-flexbox;
display: flex;
-webkit-box-pack: justify;
-ms-flex-pack: justify;
justify-content: space-between;
}
.navbar .mobile-menu {
cursor: pointer;
}
.hero {
text-align: center;
margin-top: 3em;
}
.left-col h1 {
font-size: 2.5em;
line-height: 1.3em;
margin-top: .2em;
-webkit-animation: transitionIn 1s;
animation: transitionIn 1s;
}
.left-col .primary-cta {
background: var(--primary-color);
color: white;
border: 3px var(--primary-color) solid;
text-decoration: none;
padding: .6em 1.3em;
font-size: 1.4em;
border-radius: 5em;
font-weight: bold;
display: inline-block;
-webkit-transition: all 300ms ease;
transition: all 300ms ease;
}
.left-col .primary-cta:hover, .left-col .primary-cta:focus {
background-color: #F2F2F2F2;
color: var(--primary-color);
border: 3px var(--primary-color) solid;
}
.hero-img {
width: 70%;
margin-top: 3em;
-webkit-animation: opacityIn 3s;
animation: opacityIn 3s;
}
nav.menu-btn {
display: block;
}
nav {
position: fixed;
z-index: 999;
width: 66%;
right: 0;
top: 0;
background: #20272E;
height: 100vh;
padding: 1em;
}
nav ul.primary-nav {
margin-top: 5em;
}
nav li a {
color: white;
text-decoration: none;
display: block;
padding: .5em;
font-size: 1.3em;
text-align: right;
}
nav li a:hover {
color: var(--primary-color);
font-weight: bold;
}
.mobile-menu-exit {
float: right;
margin: .5em;
cursor: pointer;
}
#media only screen and (min-width: 768px) {
.mobile-menu, .mobile-menu-exit {
display: none;
}
.navbar .container {
display: -ms-grid;
display: grid;
-ms-grid-columns: 180px auto;
grid-template-columns: 180px auto;
}
.navbar nav {
display: -webkit-box;
display: -ms-flexbox;
display: flex;
-webkit-box-pack: justify;
-ms-flex-pack: justify;
justify-content: space-between;
background: none;
position: unset;
height: auto;
width: 100%;
padding: 0;
}
.navbar nav ul {
display: -webkit-box;
display: -ms-flexbox;
display: flex;
}
.navbar nav a {
color: black;
font-size: 1em;
padding: .1em 1em;
}
.navbar nav ul.primary-nav {
margin: 0;
}
.hero-img {
width: 30%;
margin-top: 6em;
}
}
#media only screen and (min-width: 1080px) {
.container {
width: 1080px;
margin: 0 auto;
}
section {
padding: 4em 4em;
}
.hero .container {
display: -webkit-box;
display: -ms-flexbox;
display: flex;
-webkit-box-pack: justify;
-ms-flex-pack: justify;
justify-content: space-between;
text-align: left;
}
.hero .container .left-col {
margin: 0 3em 0 5em;
}
.hero .container .left-col h1 {
font-size: 3em;
width: 90%;
}
.hero-img {
width: 30%;
margin-right: 8em;
}
.hero-cta {
margin-left: 2em;
}
}
/*# sourceMappingURL=main.css.map */
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>JEFDocs | All Docs | Template</title>
<link rel="stylesheet" href="css/main.css">
<link rel="stylesheet" href="css/module.css">
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/highlight.js/10.0.3/styles/default.min.css">
<script src="https://cdnjs.cloudflare.com/ajax/libs/highlight.js/10.0.3/highlight.min.js"></script>
<script>hljs.initHighlightingOnLoad();</script>
</head>
<body>
<div class="navbar">
<div class="container">
<a class="logo" href="index.html">JEF<span>Docs</span></a>
<img id="mobile-cta" class="mobile-menu" src="images/menu.svg" alt="Open Navigation">
<nav>
<img id="mobile-exit" class="mobile-menu-exit" src="images/exit.svg" alt="Close Navigation">
<ul class="primary-nav">
<li class="current">All Docs</li>
<li>GitHub</li>
<li>About</li>
</ul>
</nav>
</div>
</div>
<div class="docs-content">
<div class="left-space">
<p>In this page</p>
<ul class="left-nav">
<li>Item1</li>
<li>Item2</li>
</ul>
</div>
<div class="right-space">
<!-------------------------------------------------------------------------------------------------------------------------------->
<h1 id="1">Main Title</h1>
<h3>Subtitle</h3>
<p>
Paragraph
With code:
<pre><code class="pyton">print("Hello world")
x=10
print(x)</code></pre>
Lorem ipsum dolor sit amet, consectetur adipisicing elit. Cum saepe expedita commodi consectetur ipsum. Deleniti delectus, quas voluptatibus eum dolore accusamus aliquid voluptate a error sunt dolores mollitia. At, mollitia.
A nulla eligendi provident exercitationem! Minus perspiciatis eum vel similique, ducimus illum qui sint magnam, asperiores adipisci nesciunt in, rem assumenda repellendus! Blanditiis corporis, quidem dolore expedita consectetur aliquid eius!
Similique, provident illo nihil, unde iure perspiciatis corrupti, eius ad sint consequuntur asperiores error harum? Laborum beatae in dolorem ullam itaque quos deleniti quae debitis, magnam autem ipsa deserunt? Illo!
Nesciunt perspiciatis a corporis necessitatibus sed asperiores voluptas error saepe tempora rem voluptatibus quae ipsa molestias soluta nostrum, non sunt accusamus fuga numquam ut illo dicta! Deleniti magni doloribus ea.
Odio, quas fugiat harum eos animi suscipit dolorum ipsam aliquid perspiciatis, vitae quam assumenda soluta voluptas delectus? Placeat, repellat. Voluptatibus sint blanditiis explicabo similique, exercitationem et tempora consequatur ex asperiores!
Animi vel dignissimos inventore eligendi quisquam alias vitae earum itaque neque fugiat rem amet culpa atque delectus quod, tenetur praesentium in autem porro quam qui reprehenderit! Corrupti soluta qui illum.
Ut at sint, eius aperiam vitae, magni vel harum distinctio excepturi iusto laborum itaque deserunt cumque eaque. Qui ex quas blanditiis repellat, temporibus ab inventore perferendis sapiente cum quo laborum?
Sunt tempora possimus culpa odit numquam, nobis commodi quod, vero repellat autem nostrum laboriosam. Consequuntur hic excepturi in amet unde voluptatibus a? Optio officia obcaecati voluptatem quod dolores minus doloribus?
Nihil alias nesciunt veniam modi similique blanditiis officiis, ratione obcaecati dolores aliquid quos iusto ducimus excepturi voluptas expedita, laboriosam corrupti illum quibusdam doloribus quaerat? Quaerat neque quia impedit atque vel.
Veritatis placeat officia maiores inventore laborum illo enim vitae, ratione, dolorem esse est! Omnis, libero facere eaque vitae fuga ullam cumque consequatur porro ab recusandae, soluta facilis? Quasi, rem voluptate?
Soluta eius molestiae nemo, maiores dolore ratione placeat! Esse, doloribus tempora sint sed rem reiciendis corrupti. Sit mollitia veniam tempora iusto ipsa voluptate quod, eaque veritatis quasi iste hic quas!
Corporis pariatur, esse ipsum labore alias accusamus voluptatem veritatis ipsa possimus deserunt veniam deleniti facilis aliquam magni quidem, eligendi tempore ab dicta amet optio nesciunt provident voluptas eaque? Inventore, ducimus.
Numquam, deserunt voluptatibus veritatis est omnis ducimus ab tempora cupiditate fuga deleniti officiis velit molestiae facilis eveniet debitis, reprehenderit iure repellendus impedit animi dolorum culpa nostrum rerum illo! Quidem, soluta.
Corrupti sapiente eius necessitatibus nostrum incidunt, modi, in quae accusantium totam minima ducimus, aperiam nulla velit eos. Adipisci dignissimos eveniet, quia, voluptatibus unde repellat aperiam doloremque mollitia fugiat minus dolor.
Maxime sequi pariatur, quod, esse animi placeat quibusdam excepturi doloremque consectetur culpa commodi enim. Autem voluptas quasi excepturi natus laborum quas ad voluptatibus adipisci repellendus quia, ratione minus cupiditate itaque.
Voluptate repellendus id molestiae ipsam impedit aspernatur facere magni. Eveniet aut praesentium officiis ea fugit tenetur pariatur, veritatis deserunt! Beatae, vero odit. Aliquam delectus ipsam maxime repellat tenetur, doloribus iure.
Aspernatur vel suscipit sequi enim recusandae ratione perspiciatis, facere, fugiat incidunt, error iusto quibusdam consectetur eos. Quasi vel neque aperiam aliquid rerum, facilis cupiditate deleniti voluptate modi, nihil sunt distinctio.
</p>
<h1 id="2">Second Title</h1>
<p>
Id totam deleniti sit, magni praesentium velit voluptatum, molestias, recusandae nulla ratione quae blanditiis numquam! Sapiente nam unde quidem. Id dolor libero ipsam dolore incidunt corrupti omnis dolorem! Tempora, impedit?
Officia at cum libero unde ipsa veritatis obcaecati est quod delectus sequi voluptatem veniam consequatur sit nobis eveniet eos ab dolore earum vero, molestias nam! Ducimus optio harum necessitatibus debitis.
Dignissimos quo aspernatur iste, itaque vel voluptates fugiat dolorem maiores assumenda repellat accusamus, illo praesentium tempora aliquid sed doloribus provident, optio quia nihil. Consectetur optio quisquam eum deserunt nostrum delectus.
At libero odio suscipit quae veniam possimus dolores eum praesentium aliquid illo, voluptates similique, dignissimos, magni alias debitis harum nemo. Officia, vel! Quis minima, nesciunt eos ipsum rem quos sed!
Ad possimus error, iste facere aut voluptatem odit, voluptatum ea eos fugiat, quas cupiditate? Dolores architecto doloribus repudiandae necessitatibus repellendus officia tenetur perspiciatis, modi fugiat aliquam, tempora unde maiores doloremque.
A, nam id et adipisci nostrum natus eligendi ducimus est quos sed eveniet? Nobis saepe placeat optio natus, atque est eius nesciunt, quaerat deleniti velit consequatur laborum molestiae error dolore?
Ducimus, quam nostrum ipsam ex dolores maxime impedit corrupti deserunt dolor quod similique. Sed nihil explicabo laudantium a aut provident, ex pariatur aspernatur minus cupiditate saepe accusamus, expedita impedit iste!
Vero vel iure, quaerat unde dolore tempora molestias eum facilis cumque consequuntur non totam aperiam cum voluptas qui nihil incidunt fugiat aliquid! Ipsum accusantium vero quod, fugiat soluta illum recusandae.
Facere veniam ut est, tempora suscipit temporibus esse exercitationem reiciendis ipsam eaque dolorum, maiores dolorem ducimus voluptatem accusantium. Dicta dolorem reiciendis rerum explicabo sint pariatur illum tenetur. Laborum, tenetur repellat!
Inventore, optio quas necessitatibus consectetur atque temporibus porro dolorem dicta incidunt eaque et unde animi! Rem eaque unde placeat accusantium repudiandae blanditiis, quod voluptate natus fuga, nisi sit adipisci totam?
Explicabo consequuntur tempore dignissimos, debitis odit mollitia incidunt atque animi esse facere, ipsa ducimus repellendus deserunt laboriosam aliquam. Autem repudiandae voluptate dicta, reiciendis quos iusto voluptates ipsum rem iure incidunt!
</p>
<!-------------------------------------------------------------------------------------------------------------------------------->
</div>
</div>
</body>
</html>
Works as expected for me. If you are wondering why the inner scroll isn't smooth, you need to set the scroll behavior on the inner container as well. Add the appropriate css.
.right-space {
scroll-behavior: smooth;
}
You will want to add smooth to the .right-space so when full screen you get smooth scrolling.
.docs-content .right-space {
margin: 2em auto;
width: 90%;
background: white;
overflow-y: scroll;
padding: 1em;
height: 100vh;
scroll-behavior: smooth;
-webkit-box-shadow: 4px 4px 15px rgba(0, 0, 0, 0.514);
box-shadow: 4px 4px 15px rgba(0, 0, 0, 0.514);
-webkit-animation: transitionRight 1s;
animation: transitionRight 1s;
}

How to add a link after ellipsis using -webkit-box?

This is the layout I want to achieve:
This is what I tried so far. The text kinda overlaps each other.
* {
box-sizing: border-box;
}
body {
background-color: #F9F9F9;
}
p {
overflow: hidden;
text-overflow: ellipsis;
display: -webkit-box;
-webkit-line-clamp: 3;
-webkit-box-orient: vertical;
width: 300px;
position: relative;
hyphens: auto;
background-color: white;
}
a {
display: block;
position: absolute;
bottom: 0;
right: 0;
}
<p>
<span>Lorem ipsum dolor, sit amet consectetur adipisicing elit. Ipsam, possimus expedita deleniti eum repudiandae rerum distinctio asperiores sit sint, nulla natus! Molestias ipsa quos reiciendis repudiandae blanditiis adipisci aperiam neque, tenetur saepe? Quidem quas modi mollitia consequatur velit earum praesentium non laudantium, vitae accusantium labore aut dolorum odio, veniam iste eum ad quisquam incidunt in expedita libero molestias impedit dignissimos? Debitis, repudiandae? Aperiam vero id, nihil tempora aliquam incidunt, nam ipsum unde odit quos, excepturi modi laudantium itaque alias illo impedit iusto ad officia nobis magni. Perferendis, velit quidem impedit rem asperiores, sint odit facilis mollitia similique nostrum, adipisci excepturi.
</span>
Show More
</p>
How can I achieve this kind of layout?
I don't think this is doable with line clamp so here is another idea to get the same effect without line-clamp. It's a bit hacky but is more supported:
You can also click the show more button:
* {
box-sizing: border-box;
}
body {
background-color: #F9F9F9;
}
p {
overflow: hidden;
width: 300px;
line-height: 1.2em;
height: calc(3 * 1.2em); /* define 3 lines*/
position: relative;
background-color: white;
}
a {
position: absolute;
bottom: 0;
right: 0;
background: inherit;
outline: none;
padding-left: 18px;
}
a:before {
content: "...";
position: absolute;
left: 0;
text-decoration: none;
color: #000;
}
p:focus-within {
height: auto;
}
p:focus-within a {
font-size:0;
}
<p>
<span>Lorem ipsum dolor, sit amet consectetur adipisicing elit. Ipsam, possimus expedita deleniti eum repudiandae rerum distinctio asperiores sit sint, nulla natus! Molestias ipsa quos reiciendis repudiandae blanditiis adipisci aperiam neque, tenetur saepe? Quidem quas modi mollitia consequatur velit earum praesentium non laudantium, vitae accusantium labore aut dolorum odio, veniam iste eum ad quisquam incidunt in expedita libero molestias impedit dignissimos? Debitis, repudiandae? Aperiam vero id, nihil tempora aliquam incidunt, nam ipsum unde odit quos, excepturi modi laudantium itaque alias illo impedit iusto ad officia nobis magni. Perferendis, velit quidem impedit rem asperiores, sint odit facilis mollitia similique nostrum, adipisci excepturi.
</span>
Show More
</p>

Div with a lot of text goes out of page upon resizing

I am trying to make a simple responsive "about" page.
Everything works till I resize the browser to a smaller window.
HTML
<div id="content">
<div id="area-container">
<h1>about</h1>
<div id="textarea">
<p>My name is...[lorem200words]</p>
</div>
</div>
</div>
CSS
body {
margin: 0 auto;
overflow: hidden;
font-family: 'Share Tech Mono', monospace;
}
#content {
width: 100%;
height: 2457px;
background-image: url('../images/wallpaper.jpg');
}
#area-container {
display:inline-block;
margin-top: 50vh;
margin-left: 50vw;
transform: translate(-50%, -60%);
}
#media screen and (max-width:800px) {
body {
overflow-y: scroll;
}
#content {
width: 100%;
height: 100%;
background-image: url('../images/connected.png');
}
}
https://jsfiddle.net/a4uaquyp/3/
The problem is that the whole textarea div seems to jump out of the browser, when I add the overflow to the body it won't let me scroll up enough.
There's also for some reason a lot of excess space below.
I tried using media querys to somehow push the #content down a bit with margin-top and vw/vh, I can't really think of anything else.
The problem is your use of transform: translate(-50%, -60%), in combination with your margin-top: 50vh and margin-left: 50vw. While this offsets the content, it will overflow it if there is too much to display.
Instead, if you want to center a lot of content, I would recommend flexbox. This allows you to achieve your desired result with only a few lines of code:
#content {
display: flex;
align-items: center;
justify-content: center;
}
#area-container {
max-width: 50%;
}
This can be seen in the following:
#import url('https://fonts.googleapis.com/css?family=Share+Tech+Mono');
body {
margin: 0 auto;
overflow: hidden;
font-family: 'Share Tech Mono', monospace;
}
#content {
width: 100%;
background-image: url('../images/wallpaper.jpg');
display: flex;
align-items: center;
justify-content: center;
margin-bottom: 20px; /* Just to give space at the bottom */
}
#area-container {
max-width: 50%;
}
#textarea {
background-color: #fff;
box-shadow: 0 0 3em #ccc;
border-radius: 10px;
padding: 10px;
}
#area-container h1 {
text-align: center;
text-transform: uppercase;
font-size: 5vw;
}
#area-container h1:before,
#area-container h1:after {
content: '-';
font-weight: normal;
}
#media screen and (max-width:800px) {
body {
overflow-y: scroll;
}
#content {
width: 100%;
height: 100%;
background-image: url('../images/connected.png');
}
#area-container h1 {
font-size: 40px;
}
}
<body>
<div id="content">
<div id="area-container">
<h1>about</h1>
<div id="textarea">
<p>y name is... Lorem ipsum dolor sit amet, consectetur adipisicing elit. Illo odit repudiandae veritatis hic facere non aperiam sunt dolor, ut enim? Sunt tempora et saepe quae, optio fugiat, eaque corrupti dignissimos modi tenetur sint corporis
dolore. Harum sunt eligendi, facilis, quos obcaecati consequatur earum, qui molestiae ducimus inventore optio. Minus quas sed, fugit fuga culpa neque magni quisquam doloremque tempora ad, et quia possimus voluptatibus enim iusto esse omnis recusandae
in eos provident nobis totam aliquid. Iste fugit tenetur, odio voluptates impedit veritatis reiciendis. Enim eaque quod repudiandae velit eum, quo commodi, odio quasi quos laboriosam iusto dolores laborum sapiente tenetur nihil sunt, nam nostrum
at accusamus id facere magnam! Quibusdam sint, velit similique harum alias neque doloremque labore iste officia repellat quae dolorum suscipit ad nostrum eaque quisquam, amet voluptatibus, laborum sit quaerat dolorem sunt laudantium. Nam necessitatibus
repellendus ipsum officia nulla commodi. Eveniet amet fuga, dolores voluptas nemo impedit laudantium facere, eum iste officiis perspiciatis. Quae ipsa eligendi dolor laborum optio ipsam commodi temporibus sequi, adipisci nobis facere, iste deserunt
architecto rem odit ullam, tenetur fuga veniam. Sed maiores libero odio nostrum officia, dolores expedita quisquam asperiores eligendi ad soluta incidunt earum, vitae, omnis esse voluptatum perferendis ab commodi.</p>
</div>
</div>
</div>
</body>
Also note that you don't probably want to restrict the height of #content. I've removed the height: 2457px from my above snippet.

Arrows from point to point

I have a PSD which I have to convert to html. I have a problem with some elements, to be more precise I have no idea how to create it, furthermore I don't know how to name it to find examples in google. Looking for your advices. Those arrows should be responsive(become longer or shorter)
I would give the background the dashed lines. Then I would position the icons along with their arrow heads at the top, bottom, and middle using css. Then as the element grows and shrinks the icons move with the sizing and cover the dashed lines in the background.
Here, I got you started...
.container {
box-sizing: border-box;
width: 80%;
display: flex;
flex-wrap: wrap;
flex-direction: column;
}
.top-dash {
position: relative;
width: 100%;
height: 30px;
margin-bottom: 1em;
background-color: black;
display: flex;
align-items: center;
justify-content: space-between;
}
.top-dash:before {
content: "";
position: absolute;
left: 0;
top: 13px;
width: 100%;
border-top: 5px dashed orange;
}
[class*="word"] {
display: block;
padding-right: 1em;
background-color: black;
color: orange;
font-size: 18px;
font-weight: bold;
z-index: 5;
}
[class*="word"]:first-child {
padding-left: 1em;
}
[class*="word"]:nth-child(n+2):before {
content: ">";
padding-right: 1em;
}
.content {
position: relative;
box-sizing: border-box;
width: 100%;
padding: 0 2em;
border-left: 60px solid blue;
}
.side-dash {
position: absolute;
left: -60px;
top: 0;
width: 60px;
height: 100%;
overflow: hidden;
display: flex;
}
.side-dash:before {
content: "";
position: absolute;
left: 28px;
top: 0;
height: 100%;
border-left: 5px dashed white;
}
<div class="container">
<div class="top-dash">
<span class="word-left">ONE</span>
<span class="word-mid">TWO</span>
<span class="word-right">THREE</span>
</div>
<div class="content">
<div class="side-dash">
<span class="icon-top"></span>
<span class="icon-mid"></span>
<span class="icon-bot"></span>
</div>
<p>Lorem ipsum dolor sit amet, consectetur adipisicing elit. Iusto, cupiditate, explicabo! Voluptatibus placeat quod magnam soluta, fuga molestiae consectetur doloribus distinctio ipsum voluptas labore delectus reprehenderit rem voluptate, beatae nesciunt.</p>
<p>Nisi excepturi nobis ipsam perferendis nemo ipsa! Aspernatur quaerat ad, harum sapiente? Adipisci, ea. Aperiam exercitationem unde reiciendis obcaecati dolorem sit vitae animi, ut at quisquam corporis ratione voluptatum modi!</p>
<p>Assumenda explicabo voluptatum ea porro unde quo at praesentium temporibus quae optio, laudantium ab minus vero quas, repellat nihil. Laudantium, facere. Tempora adipisci earum voluptatem deserunt atque eos fugiat debitis.</p>
<p>Lorem ipsum dolor sit amet, consectetur adipisicing elit. Iusto, cupiditate, explicabo! Voluptatibus placeat quod magnam soluta, fuga molestiae consectetur doloribus distinctio ipsum voluptas labore delectus reprehenderit rem voluptate, beatae nesciunt.</p>
<p>Nisi excepturi nobis ipsam perferendis nemo ipsa! Aspernatur quaerat ad, harum sapiente? Adipisci, ea. Aperiam exercitationem unde reiciendis obcaecati dolorem sit vitae animi, ut at quisquam corporis ratione voluptatum modi!</p>
<p>Assumenda explicabo voluptatum ea porro unde quo at praesentium temporibus quae optio, laudantium ab minus vero quas, repellat nihil. Laudantium, facere. Tempora adipisci earum voluptatem deserunt atque eos fugiat debitis.</p>
</div>
</div>

Position Absolute + Scrolling

With the following HTML and CSS
.container {
position: relative;
border: solid 1px red;
height: 256px;
width: 256px;
overflow: auto;
}
.full-height {
position: absolute;
top: 0;
left: 0;
right: 128px;
bottom: 0;
background: blue;
}
<div class="container">
<div class="full-height">
</div>
</div>
The inner div takes up the full head of the container as desired. If I now add some other, flow, content to the container such as:
.container {
position: relative;
border: solid 1px red;
height: 256px;
width: 256px;
overflow: auto;
}
.full-height {
position: absolute;
top: 0;
left: 0;
right: 128px;
bottom: 0;
background: blue;
}
<div class="container">
<div class="full-height">
</div>
Lorem ipsum dolor sit amet, consectetur adipisicing elit. Aspernatur mollitia maxime facere quae cumque perferendis cum atque quia repellendus rerum eaque quod quibusdam incidunt blanditiis possimus temporibus reiciendis deserunt sequi eveniet necessitatibus
maiores quas assumenda voluptate qui odio laboriosam totam repudiandae? Doloremque dignissimos voluptatibus eveniet rem quasi minus ex cumque esse culpa cupiditate cum architecto! Facilis deleniti unde suscipit minima obcaecati vero ea soluta odio cupiditate
placeat vitae nesciunt quis alias dolorum nemo sint facere. Deleniti itaque incidunt eligendi qui nemo corporis ducimus beatae consequatur est iusto dolorum consequuntur vero debitis saepe voluptatem impedit sint ea numquam quia voluptate quidem.
</div>
Then the container scrolls as desired, however the absolutely positioned element is no longer anchored to the bottom of the container but stops at the initial view-able bottom of the container. My question is; is there any way of having the absolutely positioned element be the complete scroll height of its container without using JS?
You need to wrap the text in a div element and include the absolutely positioned element inside of it.
<div class="container">
<div class="inner">
<div class="full-height"></div>
[Your text here]
</div>
</div>
Css:
.inner: { position: relative; height: auto; }
.full-height: { height: 100%; }
Setting the inner div's position to relative makes the absolutely position elements inside of it base their position and height on it rather than on the .container div, which has a fixed height. Without the inner, relatively positioned div, the .full-height div will always calculate its dimensions and position based on .container.
* {
box-sizing: border-box;
}
.container {
position: relative;
border: solid 1px red;
height: 256px;
width: 256px;
overflow: auto;
float: left;
margin-right: 16px;
}
.inner {
position: relative;
height: auto;
}
.full-height {
position: absolute;
top: 0;
left: 0;
right: 128px;
bottom: 0;
height: 100%;
background: blue;
}
<div class="container">
<div class="full-height">
</div>
</div>
<div class="container">
<div class="inner">
<div class="full-height">
</div>
Lorem ipsum dolor sit amet, consectetur adipisicing elit. Aspernatur mollitia maxime facere quae cumque perferendis cum atque quia repellendus rerum eaque quod quibusdam incidunt blanditiis possimus temporibus reiciendis deserunt sequi eveniet necessitatibus
maiores quas assumenda voluptate qui odio laboriosam totam repudiandae? Doloremque dignissimos voluptatibus eveniet rem quasi minus ex cumque esse culpa cupiditate cum architecto! Facilis deleniti unde suscipit minima obcaecati vero ea soluta odio
cupiditate placeat vitae nesciunt quis alias dolorum nemo sint facere. Deleniti itaque incidunt eligendi qui nemo corporis ducimus beatae consequatur est iusto dolorum consequuntur vero debitis saepe voluptatem impedit sint ea numquam quia voluptate
quidem.
</div>
</div>
http://jsfiddle.net/M5cTN/
position: fixed; will solve your issue. As an example, review my implementation of a fixed message area overlay (populated programmatically):
#mess {
position: fixed;
background-color: black;
top: 20px;
right: 50px;
height: 10px;
width: 600px;
z-index: 1000;
}
And in the HTML
<body>
<div id="mess"></div>
<div id="data">
Much content goes here.
</div>
</body>
When #data becomes longer tha the sceen, #mess keeps its position on the screen, while #data scrolls under it.
So gaiour is right, but if you're looking for a full height item that doesn't scroll with the content, but is actually the height of the container, here's the fix. Have a parent with a height that causes overflow, a content container that has a 100% height and overflow: scroll, and a sibling then can be positioned according to the parent size, not the scroll element size. Here is the fiddle: http://jsfiddle.net/M5cTN/196/
and the relevant code:
html:
<div class="container">
<div class="inner">
Lorem ipsum ...
</div>
<div class="full-height"></div>
</div>
css:
.container{
height: 256px;
position: relative;
}
.inner{
height: 100%;
overflow: scroll;
}
.full-height{
position: absolute;
left: 0;
width: 20%;
top: 0;
height: 100%;
}
.container {
position: relative;
border: solid 1px red;
height: 256px;
width: 256px;
overflow: auto;
}
.full-height {
position: absolute;
top: 0;
left: 0;
right: 128px;
bottom: 0;
background: blue;
}
<div class="container">
<div class="full-height">
</div>
</div>
I ran into this situation and creating an extra div was impractical.
I ended up just setting the full-height div to height: 10000%; overflow: hidden;
Clearly not the cleanest solution, but it works really fast.
Not that there's anything wrong with any of the other answers, but just for fun, I copied the original snippet and all I changed was height to min-height and I didn't have to add another <div> anywhere.
.container {
position: relative;
border: solid 1px red;
min-height: 256px;
width: 256px;
overflow: auto;
}
.full-height {
position: absolute;
top: 0;
left: 0;
right: 128px;
bottom: 0;
background: blue;
}
<div class="container">
<div class="full-height">
</div>
Lorem ipsum dolor sit amet, consectetur adipisicing elit. Aspernatur mollitia maxime facere quae cumque perferendis cum atque quia repellendus rerum eaque quod quibusdam incidunt blanditiis possimus temporibus reiciendis deserunt sequi eveniet necessitatibus
maiores quas assumenda voluptate qui odio laboriosam totam repudiandae? Doloremque dignissimos voluptatibus eveniet rem quasi minus ex cumque esse culpa cupiditate cum architecto! Facilis deleniti unde suscipit minima obcaecati vero ea soluta odio cupiditate
placeat vitae nesciunt quis alias dolorum nemo sint facere. Deleniti itaque incidunt eligendi qui nemo corporis ducimus beatae consequatur est iusto dolorum consequuntur vero debitis saepe voluptatem impedit sint ea numquam quia voluptate quidem.
</div>
.bottomDiv {
position: relative;
bottom: 0;
}
.parentDiv {
display: flex;
flex-direction: column;
}
.theDivPlacedOnTopofBottomDiv {
flex-grow: 1 !important;
}