How do I reproduce YouTube's "Show More" functionality? [closed] - php

It's difficult to tell what is being asked here. This question is ambiguous, vague, incomplete, overly broad, or rhetorical and cannot be reasonably answered in its current form. For help clarifying this question so that it can be reopened, visit the help center.
Closed 10 years ago.
I want to reproduce YouTube's "Show More" functionality on my site. Below each video, there's a "Show More" link. If you click on that link, it moves down, and some previously-hidden text is shown. How can I do this?

A CSS-only version I just did: http://dabblet.com/gist/3157489
It works in Chrome, Firefox, Safari, Opera, IE9+. Show/ hide is functional in IE9, though transitions are missing (gradient fade is emulated using an additional element).
The HTML structure is something like:
<div class="info-wrapper">
<input type="checkbox" id="showhide">
<label for="showhide">
<div class="more">Show more</div>
<div>Show less</div>
</label>
<div class="info">
<p><!-- text, text, more text --></p>
<!--[if lte IE 9]><div class="aftershadow"></div><![endif]-->
</div>
</div>
The CSS:
body {
background: #ccc;
}
.info-wrapper {
height: auto;
width: 500px;
margin: 4em auto;
padding: 0 0 2em 0;
position: relative;
}
.info {
max-height: 120px;
height: auto;
padding: .5em 0;
border-bottom: solid 1px #fff;
border-radius: 0 0 1em 1em;
overflow: hidden;
position: relative;
transition: 1s;
}
p { margin: 1em; }
.info:after, .aftershadow {
bottom: 0;
width: 100%;
height: 3em;
border-radius: 0 0 1em 1em;
position: absolute;
background: linear-gradient(rgba(192,192,192,0), #ccc);
content: '';
}
.aftershadow {
filter: progid:DXImageTransform.Microsoft.gradient(startColorstr=#00cccccc, endColorstr=#ffcccccc);
}
.info-wrapper input[type=checkbox] {
display: none;
}
.info-wrapper label {
left: 50%;
bottom: 1.5em;
width: 9em;
height: 1.25em;
margin: 0 0 0 -2.5em;
border-bottom: solid 1px #fff;
border-radius: 0 0 1em 1em;
overflow: hidden;
position: absolute;
font: 700 .67em/1.25em Arial;
text-align: center;
text-shadow: 0 1px 0 #fff;
cursor: pointer;
}
.info-wrapper label .more { margin: -.1em 0 .35em; transition: 1s; }
.info-wrapper input[type=checkbox]:checked ~ .info {
max-height: 15em;
}
.info-wrapper input[type=checkbox]:checked + label .more {
margin-top: -1.65em;
}
The idea is the following: in the HTML structure, you have a checkbox which is hidden, but can be checked/ unchecked by clicking its label.
Initially, the info is compacted and the checkbox is unchecked. Clicking on "Show more" (which is inside the label) ticks the checkbox and you can now change the style of the elements that are its siblings and come after it in the HTML (the label and the .info in this case) using the :checked pseudo-class and the the general sibling selector.
This is the part that does it:
.info-wrapper input[type=checkbox]:checked ~ .info {
max-height: 15em;
}
.info-wrapper input[type=checkbox]:checked + label .more {
margin-top: -1.65em;
}
Another method that would also work in IE8 would be to use links and their :focus/ :active pseudo-classes instead of a checkbox and its :checked pseudo-class. The disadvantage of this method is that as soon as you click anywhere else in the page, the .info gets compacted again.
Demo: http://jsfiddle.net/thebabydino/U7Cyk/
HTML doesn't change much, I'm just replacing the checkbox and the label with two links
<div class="info-wrapper">
Show more
Show less
<div class="info">
<p><!--stuff, not wasting space here with it--></p>
<!--[if lte IE 9]><div class="aftershadow"></div><![endif]-->
</div>
</div>
The CSS is mostly the same. Everything related to input & label is out and instead there is:
.info-wrapper a {
left: 50%;
bottom: 1.5em;
width: 9em;
height: 1.25em;
margin: -.1em 0 .35em -4.5em;
border-bottom: solid 1px #fff;
border-radius: 0 0 1em 1em;
display: block;
overflow: hidden;
position: absolute;
color: #000;
font: 700 .67em/1.25em Arial;
text-align: center;
text-decoration: none;
text-shadow: 0 1px 0 #fff;
transition: 1s;
cursor: pointer;
}
.info-wrapper a:focus { outline: none; }
.info-wrapper .less {
margin-top: -1.5em;
opacity : 0;
z-index: -1;
}
.info-wrapper .more:focus ~ .info,
.info-wrapper .more:active ~ .info {
max-height: 15em;
}
.info-wrapper .less:focus ~ .info,
.info-wrapper .less:active ~ .info {
max-height: 120px;
}
.info-wrapper .more:focus,
.info-wrapper .more:active {
opacity: 0;
}
.info-wrapper .more:focus + .less,
.info-wrapper .more:active + .less {
opacity: 1;
z-index: 1;
}
Using jQuery - demo http://jsfiddle.net/thebabydino/yDfTq/
$('.more').click(function(){
$(this).animate({'opacity': '0'}, 1000);
$('.less').animate({
'opacity': '1',
'z-index': '1'
}, 1000);
$('.info').animate({'height': '15em'}, 1000);
});
$('.less').click(function(){
$(this).animate({
'opacity': '0',
'z-index': '-1'
}, 1000);
$('.more').animate({'opacity': '1'}, 1000);
$('.info').animate({'height': '120px'}, 1000);
});
​The HTML is the same and the CSS is also mostly the same:
.info {
height: 120px;
padding: .5em 0;
border-bottom: solid 1px #fff;
border-radius: 0 0 1em 1em;
overflow: hidden;
position: relative;
}
p { margin: 1em; }
.info:after, .aftershadow {
bottom: 0;
width: 100%;
height: 3em;
border-radius: 0 0 1em 1em;
position: absolute;
background: linear-gradient(rgba(192,192,192,0), #ccc);
content: '';
}
.aftershadow {
filter: progid:DXImageTransform.Microsoft.gradient(startColorstr=#00cccccc, endColorstr=#ffcccccc);
}
.info-wrapper a {
left: 50%;
bottom: 1.5em;
width: 9em;
height: 1.25em;
margin: -.1em 0 .35em -4.5em;
border-bottom: solid 1px #fff;
border-radius: 0 0 1em 1em;
display: block;
overflow: hidden;
position: absolute;
color: #000;
font: 700 .67em/1.25em Arial;
text-align: center;
text-decoration: none;
text-shadow: 0 1px 0 #fff;
cursor: pointer;
}
.info-wrapper a:focus { outline: none; }
.info-wrapper .less { margin-top: -1.5em; opacity: 0; z-index: -1; }

One of the tags indicates you're willing to use jQuery. The following link explains how this effect can be achieved with slideToggle. The style of the div or other element should be set display: none; if you want it to be hidden on the first page load.
http://www.mkyong.com/jquery/jquery-slideup-slidedown-and-slidetoggle-example/
$("#slideToggle").click(function () {
$('.slideTogglebox').slideToggle();
});
Official documentation: http://api.jquery.com/slideToggle/

Related

Is there a way to make an overlay with an arrow AND border like google?

I am working on my code to create a green circle with your name on it with an arrow and border just like the one that google use.
please find the sample image below.
I have already created a green circle and a name using css and html which you can see it here.
<div class="profileImage">
<span id="profilename" class="profilename"></span>
<div class="flex-container">
</div>
</div>
.profileImage {
-webkit-background-size: 32px 32px;
background-size: 32px 32px;
background-color: green;
-webkit-border-radius: 50%;
border-radius: 50%;
display: block;
float: right;
margin-right: 18px;
margin-top: 12px;
overflow: hidden;
position: relative;
height: 32px;
width: 32px;
z-index: 0;
}
.profilename {
text-align: center;
color: white;
font-size: 14px;
line-height: 32px;
margin-left: 5px;
font-weight: bold;
}
.flex-container {
padding: 0;
margin: 0;
list-style: none;
display: -webkit-box;
display: -moz-box;
display: -ms-flexbox;
display: -webkit-flex;
display: flex;
-webkit-flex-flow: row wrap;
justify-content: space-around;
}
$(document).ready(function() {
var firstName = 'Robert';
var lastName = 'Jones';
var intials = firstName.charAt(0)+""+lastName.charAt(0);
document.getElementById("profilename").innerHTML = intials;
});
When I click on a green circle, I want to display the overlay with a border but I have got no idea how to do this. I tried to find it on google but I couldn't find it.
Can you please show me an example how I can display the overlay with a grey border that come with my first name, last name, email address and a signout button?
Thank you.
Ok I'll get you started with an overlay that includes an arrow with a border around the whole thing.
Basically, you're doing a bit of "visual miss direction". We used CSS borders to generate a triangle of the SAME color as the box background. This gets positioned its (height - border width) above the box. This puts the triangle OVER the top of the border, effectively hiding it.
Then there's a second triangle with a color that matches the border of the box. We position this triangle BEHIND the first triangle (using z-index) and offset the second triangle the border width from the first. This makes for a "fake" border because only the border width of the second triangle shows.
body {
margin: 50px;
}
.overlay {
position: absolute;
width: 300px;
height: 200px;
// styling
background-color: #fff;
border: 1px solid #ccc;
box-shadow: 0 2px 4px 0 rgba(0,0,0,0.2);
border-radius: 4px;
}
.arrow {
position: absolute;
width: 0;
height: 0;
border-style: solid;
border-width: 0 10px 10px 10px;
border-color: transparent transparent #fff transparent;
top: -9px;
right: 10px;
}
.arrow:after {
content:"";
position: absolute;
width: 0;
height: 0;
border-style: solid;
border-width: 0 10px 10px 10px;
border-color: transparent transparent #ccc transparent;
left:-10px;
top:-1px;
z-index:-1;
}
<div class="overlay">
<div class="arrow"></div>
<div class="overlayContent">
</div>
</div>
We used two elements (arrow and content) inside the overlay wrapper because we're rounding the corners using overflow:hidden this would cause our arrows to be cut off as well. So instead we'll have an extra container. The content area uses flexbox to push the button bar to the bottom regardless of the size. There are other ways to do this but this is easy.
body {
margin: 50px;
}
.overlay {
position: absolute;
width: 300px;
height: 200px;
// styling
background-color: #fff;
border: 1px solid #ccc;
box-shadow: 0 2px 4px 0 rgba(0,0,0,0.2);
border-radius: 4px;
}
.arrow {
position: absolute;
width: 0;
height: 0;
border-style: solid;
border-width: 0 10px 10px 10px;
border-color: transparent transparent #fff transparent;
top: -9px;
right: 10px;
}
.arrow:after {
content:"";
position: absolute;
width: 0;
height: 0;
border-style: solid;
border-width: 0 10px 10px 10px;
border-color: transparent transparent #ccc transparent;
left:-10px;
top:-1px;
z-index:-1;
}
.overlayContent {
position:absolute;
z-index: 1;
top:0; right:0; bottom:0; left:0;
overflow:hidden;
border-radius: 4px;
display:flex;
flex-direction: column;
justify-content: space-between;
}
.top {
flex-basis: 70%;
}
.bottom {
flex-basis: 30%;
border-top: 1px solid #ccc;
background-color: #f5f5f5;
}
<div class="overlay">
<div class="arrow"></div>
<div class="overlayContent">
<div class="top"></div>
<div class="bottom"></div>
</div>
</div>
That's the fundamentals of the overlay. Try filling in the content you want and ask more questions if you need help.

Flipster P goes outside of parent div

I am making a flipster slider where people can give reviews about a company. But the text is flowing outside of the div. I tried numerous things but I cant get it to work like I want it. This is what I have:
https://imgur.com/dfLlUSg
and this is what I want:
https://imgur.com/f61MFCf
I am using the Advanced Custom Fields Repeater field.
Also, the two lines of text (above the picture) does not have any whitespaces, I don't know why.
This is how its built:
https://imgur.com/MX49WWB
can anyone help me with this?
This is some extra SCSS:
.flipster {
//margin-top: 75px;
ul {
height: 483px !important;
margin-top: 5px;
.flipster__item--current article {
box-shadow: 0px 0px 20px 3px rgba(0, 0, 0, 0.2);
}
li {
&.flipster__item--future {
.flipster__item__content {
//transform: rotate(0) !important;
}
}
&.flipster__item--past {
.flipster__item__content {
//transform: rotate(0) !important;
}
}
article,
.flipster article {
padding: 45px;
width: 460px;
margin: 10px auto;
height: 460px;
background: #fff;
box-shadow: 0px 0px 20px 3px rgba(0, 0, 0, .1);
.quote {
text-align: center;
p {
font-size: 32px;
text-align: center;
}
}
.quote-persoon {
p {
font-size: 18px;
color: $oranje;
text-align: center;
padding: 35px 0 5px 0;
display: block;
}
span {
font-size: 16px;
width: 100%;
display: block;
text-align: center;
}
img {
margin: 35px auto 0 auto;
display: block;
border-radius: 75px;
}
}
}
}
}
.flipster__button {
opacity: 1;
svg {
color: $oranje;
}
}
}
When I reload the page, I can see it is all inside the div how it should be but then it just quickly jumps out
I found the problem. it was in the ul.flipster__container. there was a css line: white-space: nowrap;
no idea why that would be of any use

Why do the images and text in the html page are also displayed on the popup in this code?[ PHTML]

I have used following css classes to create a popup box for a button click event.
<style type="text/css">
.overlay {
position: fixed;
top: 0;
bottom: 0;
left: 0;
right: 0;
background: rgba(0, 0, 0, 0.7);
transition: opacity 500ms;
visibility: hidden;
opacity: 0;
}
.overlay:target {
visibility: visible;
opacity: 10;
}
.popup {
margin: 70px auto;
padding: 20px;
background: #fff;
border-radius: 5px;
width: 40%;
position: relative;
transition: all 5s ease-in-out;
}
.popup h2 {
margin-top: 0;
color: #333;
font-family: Tahoma, Arial, sans-serif;
}
.popup .close {
position: absolute;
top: 20px;
right: 30px;
transition: all 200ms;
font-size: 30px;
font-weight: bold;
text-decoration: none;
color: #333;
}
.popup .close:hover {
color: #06D85F;
}
.popup .content {
max-height: 30%;
overflow: auto;
}
#media screen and (max-width: 700px){
.box{
width: 70%;
}
.popup{
width: 70%;
}
}
</style>
Popup is working as expected.But when I scroll down on the popup,images and text which are not in the popup area(Which are below the popup) are also displayed as they are on the same level.I have included a screen shot of my problem.Can any one help me in this? Where have I gone wrong?
I have obtained these classes from the Bootsnip site
https://bootsnipp.com/snippets/featured/ecommerce-quick-view-popup-amp-product-row
This is the problematic view
Just add z-index: 1 to .overlay. This should fix this issue.
See CSS z-index property for more informations.
I can't see a different z-index value in this case, but If you do, just increase the number of z-index.

Text inside of link aligns incorrectly in WordPress but is fine in HTML

As you can see in the images, the text "English" isn't vertically centered in the WordPress version of the site I'm building but with the same code as I used in the HTML version it works perfectly. Any ideas why?
HTML
<div class="right-bar">
<a class="language">
<img src="img/flags/EN-us.png" alt="English / US">
<span>English</span>
</a>
<a class="search-btn">
<i class="fa fa-search"></i>
</a>
</div>
SASS
.right-bar {
background: #1f1f1f;
float: right;
height: 100%;
padding: 32px 20px 0;
position: relative;
&::after {
position: absolute;
top: 0;
right: 100%;
content: "";
width: 0;
height: 0;
border-style: solid;
border-width: 0 0 98px 83px;
border-color: transparent transparent #1f1f1f;
}
.language {
border: 1px solid #363636;
border-radius: 40px;
color: #898989;
display: block;
float: left;
height: 34px;
font-size: 10px;
font-weight: 700;
line-height: 30px;
padding: 0 20px;
position: relative;
text-transform: uppercase;
z-index: 99;
}
.search-btn {
float: left;
display: block;
margin: 0 0 0 30px;
color: #fff;
font-size: 26px;
font-weight: 400;
transition: color .2s;
&:active {
color:#8eb82f;
}
}
}
SCSS
.language{
img{
vertical-align:middle;
}
}
This may help you.

How do I change the width size of the blocks in Moodle? It is CSS? What is the file?

o css no caminho /www/moodle/theme/mytheme/style : custom.css
/* Custom CSS
-------------------------*/
body {
background: url([[pix:theme|bg]]) repeat scroll 0 0 rgba(0, 0, 0, 0);
padding-top: 60px;
color: #58585A;
font-family: "Open Sans","Helvetica Neue",Helvetica,Arial,sans-serif;
font-size: 14px;
line-height: 20px;
margin: 0;
}
#page {
padding-top: 47px;
}
a.logo {
background: url([[setting:logo]]) no-repeat 0 0;
display: block;
float: left;
height: 75px;
margin: 0;
padding: 0;
width: 100%;
}
.dir-rtl a.logo {
background: url([[setting:logo]]) no-repeat 100% 0;
display: block;
float: right;
}
.navbar-inner{
background: #F5F5F5;
}
.navbar .navbar-inner a.brand span {
display: none;
}
.navbar .navbar-inner a.brand {
background-image: url([[pix:theme|logo]]);
background-position: center center;
background-repeat: no-repeat;
min-height: 74px;
padding: 5px 20px;
width: 214px;
}
.navbar .nav {
margin-top: 17px;
}
.navbar-text, .navbar .nav > li > a{color:#E8770D;}
.breadcrumb {
border-radius: 4px;
list-style: none outside none;
margin: 0 0 20px;
padding: 8px 15px;
background-color: #FFFFFF;
border: 1px solid #E0E0E0;
}
.coursebox {
border: 1px dotted #DDDDDD;
border-radius: 4px;
margin-bottom: 15px;
padding: 5px;
background:#f5f5f5;
}
/* Custom CSS Settings
-------------------------*/
[[setting:customcss]]
Moodle puts all the css into one file for speed. To turn this off, add this line to config.php - on a development site not a production site...
$CFG->themedesignermode = true;
Then in Chrome, refresh the page, right click on the block and inspect element. It should now show the original css file.
After you have finished, remove the themedesignermode line or set it to false because it will make the site verrrry slow... http://docs.moodle.org/dev/Creating_a_theme#Theme_designer_mode
You might also need to purge the cache after making any changes - http://docs.moodle.org/26/en/Purge_all_cache

Categories