I'm working on an image grid feature in which images are being displayed. I'm facing issue regarding creating an expandable/collapsable div.
HTML
<div *ngIf="Display('images')">
<section class="image-grid" *ngFor="let item of items$|async">
<div class="image__cell is-collapsed">
<div class="image--basic">
<img (click)="expandImage()" class="basic__img" src="{{item.link}}">
</div>
<div class="image--expand" [ngClass]="{'image--expand': !_expand}">
<a class="expand__close"></a>
<img class="image--large" src="{{item.link}}">
</div>
</div>
</section>
</div>
.ts file
private _maxHeight: string;
private _marginBottom: string;
private _expand: boolean = false;
expandImage() {
this._expand = !this._expand;
this._maxHeight = '500px';
this._marginBottom = '10px';
}
CSS
.image-grid {
width: 100%;
padding-right: 30px;
padding-left: 30px;
}
.image__cell {
float: left;
position: relative;
}
.basic__img {
height: 200px;
max-width: 100%;
float: left;
overflow: hidden;
}
.image__cell.is-collapsed {
overflow: hidden;
padding: 0.6%;
}
.image__cell.is-collapsed .image--basic {
cursor: pointer;
}
.image--expand {
position: relative;
left: -5px;
padding: 0 5px;
box-sizing: content-box;
overflow: hidden;
background-color: #222;
max-height: 0;
transition: max-height .3s ease-in-out,margin-bottom .1s .2s;
}
.expand__close {
position: absolute;
top: 10px;
right: 20px;
color: #454545;
font-size: 50px;
line-height: 50px;
text-decoration: none;
}
.expand__close:before {
content: '×';
}
.expand__close:hover {
color: #fff;
}
.image--large {
max-width: 100%;
height: auto;
display: block;
padding: 40px;
margin: 0 auto;
box-sizing: border-box;
}
The code above creates an expandable div. But the problem is whenever, I click on any one image, the div gets expanded in each row. I'm trying to create similar to this: Recreating image-viewer. It would be great if someone can help me out in this. Thanks. :)
I am guessing here,
Pass clicked key to this functions (click)="expandImage(item.$key)"
and in your code
expandImage(key) {
this._expand = !this._expand;
this.clickedItem = key;
this._maxHeight = '500px';
this._marginBottom = '10px';
}
and in your template
<div class="image--expand" *ngIf="clickedItem == item.$key" [ngClass]="{'image--expand': !_expand}">
<a class="expand__close"></a>
<img class="image--large" src="{{item.link}}">
</div>
Related
I have been looking everywhere for a solution to my problem, but nothing seems to work. It always bugged me that the top of my website always had a gap on the top and all the answers to the problem did nothing. I inspected the website in firefox and found that there was a whitespace between the body and first div (I tried putting the code on the same row but that did nothing). Any Idea on how to remove the whitespace? (I can remove it in inspect on firefox and it goes away there)
Here is the HTML and CSS:
/* CSS Document */
html,
body {
height: 100%;
}
* {
overflow: auto;
margin: 0;
}
body {
margin: 0;
background-color: #111111;
padding: 0;
font-family: verdana;
box-sizing: border-box;
font-size: 1rem;
font-weight: 400;
color: white;
text-align: left;
}
video {
width: 100%;
z-index: 0;
}
.menubar {
left: 100;
}
.ulmenubar {
list-style-type: none;
margin: 0;
padding: 0;
position: fixed;
top: 0;
width: 100%;
z-index: 1;
}
.ulmenubar a {
float: left;
}
.space {
margin: 0;
padding: 0;
}
.rightside {
float: right;
}
.ulmenubar a {
display: block;
color: whitesmoke;
text-align: center;
padding: 14px 16px;
text-decoration: none;
}
.ulmenubar a:hover {
color: grey;
}
::-webkit-scrollbar {
width: 10px;
}
::-webkit-scrollbar-track {
background: #181818;
}
::-webkit-scrollbar-thumb {
background: white;
border-radius: 10px;
}
.row {
display: flex;
}
.column {
flex: 33.33%;
padding: 5px;
}
#contact {
width: 200px;
margin-left: auto;
margin-right: auto;
}
#cover {
position: fixed;
top: 0;
left: 0;
background: rgba(0, 0, 0, 0.6);
z-index: 5;
width: 100%;
height: 100%;
display: none;
}
<div class="menubar">
<ul class="ulmenubar">
<div class="rightside">
Home
Portfolio
About
Contact
</div>
</ul>
</div>
<div class="space"><video id="background-video" autoplay="" loop="" muted=""><source src="vid.mp4" type="video/mp4"></video></div>
<div id="vids"></div>
<div class="row">
<div class="column">
<img src="https://media0.giphy.com/media/xT8qBoDhee6aWOhLqw/giphy.gif?cid=790b7611a86749120009311d9c18651c96962c8e7e27def2&rid=giphy.gif&ct=g" alt="Sea" style="width:100%">
</div>
<div class="column">
<a onclick="openWin()"><img src="https://media4.giphy.com/media/UxTZDNv0Zej4s/giphy.gif?cid=790b76118b066a194adc23988667623a5aea3c7b55f3c44b&rid=giphy.gif&ct=g" alt="Forest" style="width:100%"></a>
</div>
<div class="column">
<img src="https://media4.giphy.com/media/l41lQIclE3lItAlfq/giphy.gif?cid=ecf05e47mgmmt0kas0kp9zc0435gcanw878chwmk129z9uhf&rid=giphy.gif&ct=g" alt="Sky" style="width:100%">
</div>
</div>
* {
margin: 0px;
padding: 0px;
}
Add this to your CSS
After many hours of trying, I figured out what the problem was. This may not be the case but when I went into the HTML file on text edit, I saw two <body> on the top, I deleted one and also deleted the space between <head> and <body>. It worked.
[![How to restrict the autocomplete div tags height without affecting the bottom fields.
Here when i'm searching for country references dropdown is showing, but the entire height is increasing.
here the dropdown is fall over the communication field. How to achieve this. Please find the PIC for better understanding Thanks.`
Country Reference
<div class="form-group right">
<label for="Communication_Type" class="label-title">Communication Type</label>
<div class="autocomplete1">
<input type="text" class="" id="empid1" name="empid1">
<div class="dialog1">
<ul id="charactersList1"></ul>
</div>
</div>
</div>
.cref_container {
background-color: yellow;
}
.label_cref {
display: inline-block;
margin-left: 25px;
padding: 5px;
width: 30%;
margin-top: 2px;
background-color: royalblue;
}
.autocomplete {
/* background: #fff; */
position: relative;
}
.autocomplete .close {
position: absolute;
font-size: 13px;
z-index: 10;
top: 10px;
left: calc(100% - 50px);
color: #aaa;
cursor: pointer;
display: none;
}
.autocomplete .close.visible {
display: block;
}
.dialog {
width: 60%;
margin-left: 40%;
display: none;
min-height: 40px;
max-height: 330px;
overflow: scroll;
border-top: 1px solid #f4f4f4;
}
.dialog.open {
display: block;
}
.dialog div {
padding: 20px 10px;
font-size: 13px;
cursor: pointer;
transition: all 0.2s;
}
.dialog div:hover {
background: #f2f2f2;
}`]1]1
You have two options:
either use a native "select" input component which already does that (see https://www.w3schools.com/tags/tag_select.asp)
set your "dialog1"'s position to "fixed" and set its "left" and "top" from javascript. "fixed" position takes it out of the normal layout and doesn't push around any other elements.
const leftCoordinate = 20;
const topCoordinate = 100;
document.getElementsByClassName("dialog1")[0].style.left = leftCoordinate;
document.getElementsByClassName("dialog1")[0].style.top = topCoordinate;
.dialog1 {
position: fixed;
}
I'm working on a sidebar menu and want it to be partially collapsing, which means I have to show text on hover and hide the text when not hovering. I know another question has been asked about changing another element's property on hover, but I'm having trouble changing itself and another property.
General HTML layout:
.sidebar {
position: fixed;
top: 0;
left: 0;
background-color: #1d326b;
height: 100%;
width: 60px;
transition: 0.3s;
border-radius: 0 5px 5px 0;
font-family: 'Open Sans', sans-serif;
overflow: hidden;
}
.sidebar:hover > .text {
display: block; /*Supposed to display text*/
width: 150px; /*Expands the sidebar*/
}
<div class="sidebar">
<!--more containers...-->
<!--text below is deeply nested-->
<p class="text">Displayed Text</p>
</div>
Is there a pure css solution to this problem? Any help would be appreciated!
I think what you are trying to achieve is the animation for the width, if that's what you want just remove > .text from the hover selector:
.sidebar {
position: fixed;
top: 0;
left: 0;
background-color: #1d326b;
height: 100%;
width: 60px;
transition: 0.3s;
border-radius: 0 5px 5px 0;
font-family: 'Open Sans', sans-serif;
overflow: hidden;
color: #FFF;
}
.sidebar:hover {
display: block; /*Supposed to display text*/
width: 150px; /*Expands the sidebar*/
}
.text {
width: 150px;
display: none;
}
.sidebar:hover .text {
display: block;
}
<div class="sidebar">
<!--more containers...-->
<!--text below is deeply nested-->
<p class="text">Displayed Text</p>
</div>
Would doing something like this be what you're looking for?
.text{
display: none;
}
.sidebar:hover > .text {
display: block; /*Supposed to display text*/
width: 150px; /*Expands the sidebar*/
}
.sidebar .text {
visibility: hidden;
}
.text:hover {
display: block;
width: 150px;
}
I have a button in a div container for a scroll box with some profile info, and my goal is when you press the button the div appears (display: initial;), and when you press it again it disappears (display: none;) Any ideas?
Html:
<div>
<div class="scrollbar">
<input type="button" class="profile_info">Profile Picture
<div class="image_change">This is Blue</div>
</div>
</div>
Css:
div.scrollbar {
display: inline-block;
overflow: hidden;
background-color: #f1f1f1;
overflow: auto;
width: 250px;
height: auto;
max-height: 600px;
padding: 22px;
margin: 15px;
position: relative;
word-wrap: break-word;
}
.profile_info {
text-decoration: none;
color: Black;
cursor: pointer;
}
input.profile_info:focus {
color: Red;
}
input.profile_info:focus ~ .image_change {
display: block;
}
.image_change {
display: none;
position: relative;
height: 200px;
width: 200px;
background-color: Blue;
}
It sort of works if the "image_change" div is in the "scrollbar" div, but if you click away then it disappears.
Thanks!
Since selecting a parent element with CSS is not possible obviously its also not possible to select it's adjacent one....i would suggest the following approach using javascipt :
var image = document.getElementsByClassName('image_change')[0]
var input = document.querySelector('input')
input.addEventListener('click',function(e){
if(image.style.display == '') {
image.style.display = 'block'
} else {
image.style.display = ''
}
})
div.scrollbar {
display: inline-block;
overflow: hidden;
background-color: #f1f1f1;
overflow: auto;
width: 250px;
height: auto;
max-height: 600px;
padding: 22px;
margin: 15px;
position: relative;
word-wrap: break-word;
}
.profile_info {
text-decoration: none;
color: Black;
cursor: pointer;
}
input.profile_info:checked {
color: Red;
}
.image_change {
position: relative;
display : none;
height: 200px;
width: 200px;
background-color: Blue;
}
<div>
<div class="scrollbar">
<input type="checkbox" class="profile_info">Profile Picture
</div>
<div class="image_change">
This is a Blue div
</div>
</div>
I'm trying to avoid the modern cliche of having my own custom login system for my website, and instead I'm trying to use Facebook and Twitter as options that users can have to login to my site. After several hours of browsing, I've discovered that incorporating Facebook into my website is about as easy as tying your shoes using only your teeth.
I've managed to get the button to show up inside the proper div; however, I am unable to get the button to position itself in the center of the tag that it lives in.
My first question (of probably many) on this journey, is how can I center the button? I've tried adding a style tag to the div, and that of course didn't work since Facebook actually replaces my div. Thank you for any help you can provide.
Edit: Adding in relevant code.
Index.php:
<!--User System Start -->
<script>
window.fbAsyncInit = function() {
FB.init({
appId : '[MASKED]', // App ID
channelUrl : '[MASKED]', // Channel File
status : true, // check login status
cookie : true, // enable cookies to allow the server to access the session
xfbml : true // parse XFBML
});
// Additional initialization code here
};
// Load the SDK Asynchronously
(function(d){
var js, id = 'facebook-jssdk', ref = d.getElementsByTagName('script')[0];
if (d.getElementById(id)) { return; }
js = d.createElement('script'); js.id = id; js.async = true;
js.src = "//connect.facebook.net/en_US/all.js";
ref.parentNode.insertBefore(js, ref);
}(document));
</script>
<div id="loginWrapper">
<div id="loginBar">
<section id="loginBarLeft">
<h1>Step One: Login</h1>
<div id="fb-root"></div>
<div class="centered"><fb:login-button>Login With Facebook</fb:login-button></div>
</section>
<section id="loginBarCenter">Login Bar Center</section>
<section id="loginBarRight">Login Bar Right</section>
</div>
<div id="showHide">Login or Register</div>
</div>
<!--User System End -->
userSystem.css
#charset "utf-8";
/* CSS Document */
body {
margin-top: 0;
padding-top: 0;
}
div#loginWrapper {
width: 1024px;
height: auto;
margin: 0 auto;
position: fixed;
z-index: 2;
left: 50%;
left: 120px;
top: 0
}
div#loginBar {
width: 1024px;
height: 300px;
background: url(images/loginBar_background.png) repeat-x;
color: #006;
border-bottom-left-radius: 25px;
box-shadow: 5px 5px 5px #000;
}
div#loginBar section#loginBarLeft {
float: left;
width: 33%;
height: 300px;
}
div#loginBar section#loginBarLeft h1 {
text-align: center;
margin-top: 5px;
}
div#loginBar section#loginBarLeft .centered {
height: 100px;
width: 341px;
margin: 0 auto;
}
div#loginBar section#loginBarCenter {
float: left;
width: 33%;
height: 300px;
border-right: 1px solid #FFF;
border-left: 1px solid #FFF;
}
div#loginBar section#loginBarRight {
float: left;
width: 33%;
height: 300px;
}
div#showHide {
width: 200px;
height: 25px;
position: relative;
left: 824px;
background: #333;
color: #FFF;
text-align: center;
border-bottom-left-radius: 15px;
border-bottom-right-radius: 15px;
box-shadow: 5px 5px 5px #000;
z-index: 2;
}
div#showHide a {
color: #CCC;
text-decoration: none;
font-weight: bold;
}
div#showHide a:hover {
color: #FFF;
}
I've managed to position the fb like button before:
It shouldn't replace your div if your login button is setup similar e.g. use XFBML.
HTML
<p>Click on <span class="fb-like"><fb:like href="http://www.facebook.com/somepage" send="false" width="49" show_faces="false" font="arial"></fb:like></span> to become fan and enter lalalalala some form.</p>
CSS
.fb-like { display: inline-block; height: 28px; overflow: hidden; position: relative; top: 6px; width: 48px; }
for your specific problem you may want to try something like this:
HTML
<div class="table">
<div class="centered"><fb:login-button show-faces="false" width="200" max-rows="1"></fb:login-button></div>
</div>
CSS
.centered { display: table-cell; vertical-align: middle; }
.table { display: table; height: 400px; }