i'm trying to recreate this element
I've created the following structure:
.slider-container { max-width: 300px; margin: 100px auto; background: red; position: relative; box-sizing: content-box; }
.slider-background { background: white;
position: absolute;
top: 10px;
right: 10px;
width: 90%;
height: 90%;
text-align: right;
z-index: 1; }
.slider-background a {
padding: 15px 20px;
display: block;
}
.slider-info {
padding: 45px 30px;
}
.slider-content { position: absolute; top: 0; left: 0; z-index: 2; background: lightblue; }
<div class="slider-container">
<div class="slider-background">
more<br>info
</div>
<div class="slider-content">
<div class="slider-info">
<img src="https://via.placeholder.com/140x100"/>
<h2>
lorem<br><b>ipsum</b>
</h2>
<p>
Lorem ipsum dolor sit amet, consectetur adipiscing elit. Curabitur at dolor tristique, ultricies nisl a, egestas metus. Nam ut enim in ante volutpat convallis. Donec efficitur nisl non nisi ornare tincidunt. Mauris at justo tellus.
</p>
</div>
</div>
</div>
But i'm not sure on how to recreate the curved angle on the top div, what would be the best solution to achieve that result?
Here is an idea with pseudo element and skew transformation.
I kept only the relevant for so we can see the trick:
.slider-info {
padding: 45px 30px;
}
.slider-content {
background:
linear-gradient(lightblue,lightblue) bottom/100% calc(100% - 200px) no-repeat;
width: 300px;
margin: 20px auto;
border-radius:20px 0 20px 20px;
position:relative;
z-index:0;
overflow:hidden;
}
.slider-content::after {
content:"";
position:absolute;
z-index:-1;
top:0;
left:0;
right:0;
bottom:0;
height:200px;
background:lightblue;
transform-origin:bottom;
transform:skew(30deg);
border-radius:0 20px 0 0;
}
<div class="slider-content">
<div class="slider-info">
<img src="https://via.placeholder.com/140x100" />
<h2>
lorem<br><b>ipsum</b>
</h2>
<p>
Lorem ipsum dolor sit amet, consectetur adipiscing elit. Curabitur at dolor tristique, ultricies nisl a, egestas metus. Nam ut enim in ante volutpat convallis. Donec efficitur nisl non nisi ornare tincidunt. Mauris at justo tellus.
</p>
</div>
Related
I want to make a child div inside parents div visible if I give the child div margin-top negative value.
I have tried with position:relative and z-index, but it doesn't seems work.
Here are my code:
HTML:
<div class="main-site">
<div class="container">
<div class="overlap top-border-radius">
<div id="facultylist">
<h1>Affordable Professional Web Design</h1>
<p>Lorem ipsum dolor sit amet, consectetur adipiscing elit. Etiam eu luctus ipsum, rhoncus semper magna. Nulla nec magna sit amet sem interdum condimentum.</p>
</div>
</div>
</div>
</div>
CSS:
#facultylist {
position: relative;
}
.main-site {
padding: 50px 0;
}
.container {
width: 80%;
margin: auto;
overflow: hidden;
}
.overlap {
position: relative;
background: #fff;
margin-top: -50px;
margin-bottom: 20px;
}
.top-border-radius {
border-top: #006af4 3px solid;
border-top-right-radius: 10px;
border-top-left-radius: 10px;
}
It sounds like you're looking to remove overflow: hidden on .container:
#facultylist {
position: relative;
}
.main-site {
padding: 50px 0;
}
.container {
width: 80%;
margin: auto;
/*overflow: hidden;*/
}
.overlap {
position: relative;
background: #fff;
margin-top: -50px;
margin-bottom: 20px;
}
.top-border-radius {
border-top: #006af4 3px solid;
border-top-right-radius: 10px;
border-top-left-radius: 10px;
}
<div class="main-site">
<div class="container">
<div class="overlap top-border-radius">
<div id="facultylist">
<h1>Affordable Professional Web Design</h1>
<p>Lorem ipsum dolor sit amet, consectetur adipiscing elit. Etiam eu luctus ipsum, rhoncus semper magna. Nulla nec magna sit amet sem interdum condimentum.</p>
</div>
</div>
</div>
</div>
Can anyone help me out on how to achieve the following shown below in red?
From what I understand it is a div overlap but I can't seem to figure out how to get it like this.
Add the below mentioned style to .about-lower
position: relative;
padding-top: 15px;
Remove margin-top: 20px and add the following style to .lower-title-container
position: absolute;
top: -26px;
left: 73px;
Updated JSFiddle link is here.
One method using position: absolute
I've adding padding to the container below to ensure it doesn't overlap with the button
body {
font-family: "Helvetica", sans-serif;
margin: 0px 0px 0px 0px;
}
.header-img-container {
background-image: url(../Images/about-header-img.jpg);
background-repeat: no-repeat;
background-position: top;
background-size: cover;
height: 330px;
width: 100%;
}
.header-img {
object-fit: cover;
width: 100%;
height: 100%;
}
.about-middle {
text-align: left;
margin: auto;
width: 80%;
}
.about-middle-text {
line-height: 1.3;
margin-bottom: 50px;
margin-top: 40px;
}
.about-middle-text h2 {
margin-top: 60px;
margin-bottom: 40px;
}
.about-middle-text p {
margin-bottom: 14px;
font-size: 14px;
}
.about-lower {
background-color: #FAF8F8;
text-align: left;
padding-bottom: 30px;
}
.lower-title-container {
width: 80%;
text-align: center;
vertical-align: middle;
margin: auto;
margin-top: 20px;
z-index: 10;
position: relative;
}
.lower-title {
width: 150px;
height: 50px;
background-color: #b2b0c5;
color: white;
border-radius: 22px;
display: flex;
align-items: center;
justify-content: center;
position: absolute;
top: -25px;
}
.lower-title p {
font-weight: 100;
font-size: 20px;
vertical-align: middle;
}
.about-eagles-container {
margin-top: 40px;
}
.about-eagles {
border-bottom: 1px solid lightgray;
padding-bottom: 20px;
display: flex;
width: 80%;
align-items: center;
margin: auto;
margin-top: 20px;
margin-bottom: 20px;
padding-top: 50px;
}
.eagle-img-container {
margin-right: 30px;
height: 150px;
width: 150px;
}
.eagle-img {
height: 100%;
width: 100%;
object-fit: cover;
border-radius: 2px;
}
.eagle-img-container:hover {
background-color: rgba(225, 231, 242, 0.8);
}
.eagle-name {
margin-bottom: 30px;
font-weight: bold;
}
<div class="about-middle">
<div class="about-middle-text">
<h3>Rising Eagles</h3>
<p>Lorem ipsum dolor sit amet, populo vocent perfecto has in, phaedrum aliquando omittantur mei in, evertitur intellegebat eum ut. Vel ea nulla mentitum. Id aeterno minimum sea, at est albucius scaevola consequat. Duo facer platonem expetendis eu, eu
quando aliquip constituam sed. Ne invenire suavitate vulputate mei. Vestibulum mi sapien ac nunc vel. Pellentesque nec elit sit ac orci. Ut lectus venenatis eros diam, pellentesque natoque amet lectus felis, cursus laoreet blandit ut nulla vel libero.
Venenatis tristique cras, ut vitae, lectus ornare enim, sapien luctus lacinia, aliquam nibh libero tincidunt ut. Commodo risus amet vivamus, molestie mattis at. Mauris massa, vitae dolor etiam sed. Sit mi dignissim elementum, sit nulla nec arcu
in arcu, reprehenderit sem donec magna, nisl urna non, venenatis turpis risus duis ultrices. </p>
<p> Vitae consul quodsi ea sea, ex graeci accusam copiosae sit. Ei error accumsan mel. Quo id populo melius ceteros. Ex per magna aliquam, eos scripta integre ex. Praesent in eu tincidunt. Commodo magni porta nonummy aliquam enim neque, dapibus phasellus
sed volutpat, dui quam, parturient molestie ante massa bibendum. Pharetra in ut, aliquam pretium rutrum pretium luctus phasellus. Enim sem cras interdum, at dolor in.</p>
</div>
</div>
<div class="about-lower">
<div class="lower-title-container">
<div class="lower-title">
<p>The Eagles</p>
</div>
</div>
<!-- Iterate over accounts and build div for each -->
<div class="about-eagles-container">
<div class="about-eagles">
<div class="eagle-img-container">
<!-- Change url to link to their personal page -->
<img src="../Images/profile-img1.jpg" class="eagle-img">
</div>
<div class="eagle-text">
<p class="eagle-name">Charlie</p>
<p>Lorem ipsum dolor sit amet, nec no errem euismod ponderum. Pro no populo putant audire.</p>
</div>
</div>
<div class="about-eagles">
<div class="eagle-img-container">
<img src="../Images/profile-img2.jpg" class="eagle-img">
</div>
</div>
</div>
</div>
html:
<!-- i put the button above the first div -->
<input id="btn" type="button" value="the button"/>
<div class="about-middle">
css:
add
body {
position: relative;
}
#btn {
left: 75px;
margin: -25px 0 0 20px;
position: absolute;
top: 15px;
}
.about-middle{
border: solid 1px black; /* so it's visible. */
}
I want to manage hover event just like in the linked fiddle, assuming I don't know how long the content would be...
My question is: how can I add smooth transitions while hovering?
Fiddle
.news{
max-width:250px;
font-family:Arial, Helvitica, sans-serif;
}
.thumbs {
list-style: none;
position: relative;
padding: 0;
margin: 0;
text-align: left;
letter-spacing: -0.25em;
}
.thumbs li {
display: inline-block;
margin-top: 10px;
position: relative;
overflow: hidden;
letter-spacing: normal;
background-color: white;
border: 1px solid #CCC;
min-height:264px;
}
.thumbs .news-img-container {
height: 180px;
overflow: hidden;
z-index: 0;
}
.thumbs li a img {
display: block;
position: relative;
width: 100%;
height: auto;
}
.thumbs li a div.text {
display: block;
padding: 10px;
text-transform: none;
font-weight: 300;
text-align: left;
color: rgba(0, 0, 0, 0.9);
background-color: white;
border-top: 2px solid #8c1c40;
margin: -40px 15px 0 15px;
z-index: 1;
position: relative;
height: 100px;
overflow:hidden;
}
.thumbs li a div.text:hover {
height: 100%;
min-height:206px;
vertical-align: bottom;
margin-top: -160px;
}
.thumbs li a div.text:hover:after {
background: none;
}
.thumbs li a div.text:after {
content: '';
position: absolute;
right: 0;
bottom: 0;
left: 0;
height: 2em;
background: linear-gradient(to bottom,rgba(255,255,255,0) 0,#fff 100%);
}
.thumbs li a div.text p {
padding: 0;
margin: 0;
font-size: .9em;
}
h2 {
color:#8c1c40;
font-size:1em;
text-transform:uppercase;
margin:0 0 5px 0;
font-weight:bold;
}
a {
text-decoration:none;
}
}
<div class="news">
<ul class="thumbs">
<li>
<a href="#">
<div class="news-img-container">
<img src="http://docteurnature.org/boutique/img/cms/homepage_logo_1.jpg" />
</div>
<div class="text">
<h2>Title h2</h2>
<p>Long text: Lorem ipsum dolor sit amet, consectetur adipiscing elit. Curabitur eget ante libero. Morbi maximus urna id tellus tempus, sit amet volutpat augue venenatis. Pellentesque et fringilla ipsumorem ipsum dolor sit amet, consectetur adipiscing elit.
Curabitur eget ante libero. Morbi maximus urna id tellus tempus, sit amet volutpat augue venenatis. Pellentesque et fringilla ipsum...</p>
</div>
</a>
</li>
<li>
<a href="#">
<div class="news-img-container">
<img src="https://static.pexels.com/photos/65977/pexels-photo-65977-large.jpeg" />
</div>
<div class="text">
<h2>Title h2</h2>
<p>Shorter text :lorem ipsum dolor sit amet, consectetur adipiscing elit. Curabitur eget ante libero. Morbi maximus urna id tellus tempus, sit amet volutpat augue venenatis. Pellentesque et fringilla ipsumorem ipsum dolor sit amet, consectetur adipiscing elit.
</p>
</div>
</a>
</li>
<li>
<a href="#">
<div class="news-img-container">
<img src="https://static.pexels.com/photos/33045/lion-wild-africa-african-large.jpg" />
</div>
<div class="text">
<h2>Title h2</h2>
<p>even shorter text: lorem ipsum dolor sit amet, consectetur adipiscing elit. Curabitur eget ante libero. Morbi maximus urna id tellus tempus, sit amet volutpat augue venenatis.</p>
</div>
</a>
</li>
<li>
<a href="#">
<div class="news-img-container">
<img src="https://static.pexels.com/photos/28201/pexels-photo-28201-large.jpg" />
</div>
<div class="text">
<h2>Title h2</h2>
<p>Smallest text: lorem ipsum dolor sit amet...</p>
</div>
</a>
</li>
</ul>
</div>
Besides, It would be great that the animation launches while hovering the picture...
I'd like to avoid using js, if possible... But if not, well... why not.
Thanks a lot for your help
Here's your updated fiddle with smooth transition on hover.
https://jsfiddle.net/fhqxv36q/4/
All I have done is added some transition to .thumbs li a div.text. In this particular case, it's 0.3s for all properties that are changing on hover.
The solution, obviously doesn't take into consideration all the possible transitions and scenarios. It is here to give you an idea of what you need to do.
EDIT :
https://jsfiddle.net/fhqxv36q/7/
This takes away the transition effect when you mouse out.
Learn more about transitions here - https://developer.mozilla.org/en/docs/Web/CSS/transition
This one should do exactly what you want.
Adding the transition to both the element and its :hover state + fixed some other issues it caused.
https://jsfiddle.net/fhqxv36q/5/
I've been looking all over and failed to find a solution to this on my own. I'm trying to make a basic contenteditable code editor, and for the line numbers I have chosen to use a paragraph for each line with a counter set in a CSS pseudo element.
.editor {
display: inline-block;
border: 1px black solid;
font-family: "Consolas", "Monaco", "Courier New", monospace;
counter-reset: line;
width: 90%;
height: 350px;
overflow: scroll;
padding-left: 0;
margin-left: 0;
z-index: 1;
}
.editor p {
display: block;
counter-increment: line;
background-color: #FFF;
text-align: left;
margin: 0px;
z-index: 2;
outline: none;
}
.editor p:before {
display: inline-block;
width: 2em;
height: 100%;
border-right: 1px black solid;
padding-right: 1em;
margin-right: 1em;
content: counter(line);
color: #FFF;
background-color: #006;
text-align: right;
/*-webkit-user-select: none;
user-select: none;*/
}
<div class="editor" contenteditable="true" spellcheck="false">
<p>Some paragraph</p>
<p>Lorem ipsum dolor sit amet, consectetur adipiscing elit. Maecenas aliquet nunc non pulvinar luctus. Cras finibus turpis at arcu mollis, nec fermentum mi pretium. Aliquam suscipit lacus sapien, eu fringilla enim malesuada quis. Sed ut tincidunt erat.
In posuere vulputate venenatis. Mauris quis porta magna. Phasellus pharetra in nisl et luctus. Etiam in ultrices risus. Morbi vel dapibus ex. Suspendisse gravida libero non malesuada congue. Pellentesque ut nunc diam.</p>
<p> </p>
<p> </p>
<p> </p>
</div>
The problem is that if the paragraph is a bit longer the rest of the text will go beneath my counter pseudoelement. I want to strech the :before counter to be the same height as the paragraph.
I have tried using position:relative on the paragraph and position:absolute; height:100% on the p:before pseudoelement like explained here: How can the pseudo element detect the height of the non-pseudo element?
This does not work in my case because I don't want the p:before element to go over and cover the paragraph, I just want the same behaviour as now, just want the p:before element to strech at the same height as the main p.
I also wouldn't want to have the line strech more than the width of the wrapper container. I've been trying many methods but failed to come to a solution.
Instead of height, rather use position: relative; for p, and position: absolute; for :before.
Js Fiddle
Here are the newly added CSS properties:
.editor p {
position: relative;
padding-left: 3.5em;
.editor p:before {
position: absolute;
top: 0;
bottom: 0;
left: 0;
}
Edit
It should be a second question :D
Pressing Enter in IE will not create a br, whereas in modern browsers it creates a br using :after. Here is to guarantee so that p tag does not remain empty:
Js Fiddle
.editor {
display: inline-block;
border: 1px black solid;
font-family: "Consolas", "Monaco", "Courier New", monospace;
counter-reset: line;
width: 90%;
height: 350px;
overflow: scroll;
padding-left: 0;
margin-left: 0;
z-index: 1;
}
.editor p {
display: block;
counter-increment: line;
background-color: #FFF;
text-align: left;
margin: 0px;
z-index: 2;
outline: none;
position: relative;
padding-left: 3.5em;
}
.editor p:before {
display: inline-block;
width: 2em;
height: 100%;
border-right: 1px black solid;
padding-right: 1em;
margin-right: 1em;
content: counter(line);
color: #FFF;
background-color: #006;
text-align: right;
position: absolute;
top: 0;
bottom: 0;
left: 0;
/*-webkit-user-select: none;
user-select: none;*/
}
.editor p:after {
content: " "
}
<div class="editor" contenteditable="true" spellcheck="false">
<p>Some paragraph</p>
<p>Lorem ipsum dolor sit amet, consectetur adipiscing elit. Maecenas aliquet nunc non pulvinar luctus. Cras finibus turpis at arcu mollis, nec fermentum mi pretium. Aliquam suscipit lacus sapien, eu fringilla enim malesuada quis. Sed ut tincidunt erat.
In posuere vulputate venenatis. Mauris quis porta magna. Phasellus pharetra in nisl et luctus. Etiam in ultrices risus. Morbi vel dapibus ex. Suspendisse gravida libero non malesuada congue. Pellentesque ut nunc diam.</p>
<p>one</p>
<p>two</p>
<p>three</p>
</div>
Since you want the line numbers and lines appear in table-like manner, the natural approach is to make them table: declare the editable area as table (in the CSS sense), make the lines rows, and make the generated line numbers table cells:
.editor {
display: tablek;
border: 1px black solid;
font-family: "Consolas", "Monaco", "Courier New", monospace;
counter-reset: line;
width:90%;
height:350px;
overflow:scroll;
padding-left:0;
margin-left:0;
z-index:1;
}
.editor p {
display: table-row;
counter-increment: line;
background-color:#FFF;
text-align:left;
margin:0px;
z-index:2;
outline: none;
}
.editor p:before {
display: table-cell;
width:2em;
height:100%;
border-right: 1px black solid;
padding-right: 1em;
margin-right: 1em;
content: counter(line);
color:#FFF;
background-color:#006;
text-align:right;
/*-webkit-user-select: none;
user-select: none;*/
}
<div class="editor" contenteditable="true" spellcheck="false">
<p>Some paragraph</p>
<p>Lorem ipsum dolor sit amet, consectetur adipiscing elit. Maecenas aliquet nunc non pulvinar luctus. Cras finibus turpis at arcu mollis, nec fermentum mi pretium. Aliquam suscipit lacus sapien, eu fringilla enim malesuada quis. Sed ut tincidunt erat. In posuere vulputate venenatis. Mauris quis porta magna. Phasellus pharetra in nisl et luctus. Etiam in ultrices risus. Morbi vel dapibus ex. Suspendisse gravida libero non malesuada congue. Pellentesque ut nunc diam.</p>
<p> </p>
<p> </p>
<p> </p>
</div>
http://jsfiddle.net/zppb29jw/2/
p {
position:relative;
left: 4em;
...
p:before {
position:absolute;
right:100%
display:block;
...
is that ok for you?
.black_right{
position: relative;
display: table;
width: 100%;
z-index: 10;
}
.black_right::after{
content: " ";
top: 0px;
height: 100%;
width: 100%;
box-shadow: 500px 0px #000;
position: absolute;
}
I'm trying to making my tabs work via the radiobutton hack / checkbox hack. My tabs are positioned in the bottom and when you click them the content shows up above them, however, my tabs inactive tabs disappear. Any ideas why?
Here's my demo JSFIDDLE
HTML
<h1> id elementum risus</h1>
<div class="tabs">
<div class="tab">
<input type="radio" id="tab-1" name="tab-group-1">
<label for="tab-1">Tab One</label>
<div class="content">
Lorem ipsum dolor sit amet, consectetur adipiscing elit. Phasellus dapibus varius urna, ac venenatis arcu convallis consequat. In augue est, posuere auctor facilisis varius, dictum ac risus. Donec nibh justo, aliquam sed tempus quis, lobortis sed orci.
</div>
</div>
<div class="tab">
<input type="radio" id="tab-2" name="tab-group-1">
<label for="tab-2">Tab Two</label>
<div class="content">
Vivamus id elementum risus. In sit amet mi nulla, ac sollicitudin odio. Phasellus laoreet leo vitae velit lobortis at condimentum odio placerat. Nam sapien eros, accumsan id porttitor a, commodo ut urna. Cras dignissim metus quis enim placerat lobortis.
</div>
</div>
<div class="tab">
<input type="radio" id="tab-3" name="tab-group-1">
<label for="tab-3">Tab Three</label>
<div class="content">
Phasellus scelerisque luctus ligula, a consequat orci posuere rutrum. Sed ipsum nisi, ullamcorper eget fermentum a, dignissim sed dolor. Mauris viverra pretium ante, eu mollis nisi volutpat quis. Nunc neque erat, pharetra in feugiat eget, faucibus id sem.
</div>
</div>
</div>
CSS
.tabs {
position: relative;
min-height: 200px; /* This part sucks */
clear: both;
margin: 25px 0;
}
.tab {
float: left;
}
.tab label {
background: #eee;
padding: 10px;
margin-left: -1px;
position: relative;
left: 1px;
bottom: -10px;
}
.tab [type=radio] {
display: none;
}
.content {
position: absolute;
top: 0;
left: 0;
background: white;
right: 0;
bottom: 0;
padding: 20px;
height: 100px;
min-width: 350px;
display: none;
}
[type=radio]:checked ~ label {
background: white;
z-index: 2;
}
[type=radio]:checked ~ label ~ .content {
z-index: 1;
}
[type=radio]:checked ~ .content {
display: block;
}
[type=radio]:checked ~ label {
bottom:-149px;
}
For some reason in your code you were setting the top and bottom of content to 0 which caused it to cover the other tabs. Here is a working version:
http://jsfiddle.net/sKjc4/3/
CSS:
.tabs {
position: relative;
/* This part sucks */
clear: both;
margin: 25px 0;
min-height: 50px;
}
.tab {
float: left;
}
.tab label {
background: #eee;
padding: 10px;
margin-left: -1px;
position: relative;
left: 1px;
bottom: -10px;
}
.tab[type=radio] {
display: none;
}
.content {
position: absolute;
top: 100%;
left: 0;
background: white;
right: 0;
height: 100px;
min-width: 350px;
display: none;
}
[type=radio] {
display: none;
}
[type=radio]:checked ~ label {
background: white;
z-index: 2;
}
[type=radio]:checked ~ label ~ .content {
z-index: 1;
}
[type=radio]:checked ~ .content {
display: block;
}