I'm a real novice and trying to use a web template to design my own website.
I have a basic lightbox gallery and it all works ok, but whatever I have tried, I cannot get a caption to show on the gallery image (not the thumbnail image).
This is a snippet of the html code with a single gallery item:
<div class="gallery-item">
<div class="image">
<div class="overlay">
</div>
<img src="img/gallery/gallery-item1.jpg" alt="image 4">
</div>
I've tried using title="caption" instead of data-title ="caption", but no joy. Here is the css for the lightbox:
#lightbox {
cursor: pointer;
position: fixed;
width: 100%;
height: 100%;
top: 0;
left: 0;
background: black;
/* IE Fallback (Solid Colour) */
background: url(data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAABAAAAAQCAYAAAAf8/9hAAAAIElEQVQ4T2NkYGDYDMRkA8ZRAxhGw4BhNAyA+WAYpAMAIFgLQfO9BoEAAAAASUVORK5CYII=);
background: rgba(0, 0, 0, 0.7);
-webkit-filter: none !important;
}
#lightbox img {
display: block;
position: absolute;
border: 5px solid #fff;
box-shadow: 0 0 20px #000;
border-radius: 1px;
}
body.blurred > * {
-webkit-filter: blur(2px);
-webkit-transform: translate3d(0, 0, 0);
}
.lightbox-loading {
background: url(../img/loading.gif) center center no-repeat;
width: 31px;
height: 31px;
margin: -16px 0 0 -16px;
position: absolute;
top: 48%;
left: 50%;
}
.lightbox-caption {
display: none;
position: absolute;
left: 0;
bottom: 0;
width: 100%;
text-align: center;
z-index: 1000;
background: #000;
background: rgba(0, 0, 0, 0.7);
}
.lightbox-caption p {
margin: 0 auto;
max-width: 70%;
display: inline-block;
*display: inline;
*zoom: 1;
padding: 10px;
color: #fff;
font-size: 12px;
line-height: 18px;
}
.lightbox-button {
position: absolute;
z-index: 9999;
background: no-repeat center center;
width: 32px;
height: 32px;
opacity: 0.4;
-webkit-transition: all 0.3s;
-moz-transition: all 0.3s;
-ms-transition: all 0.3s;
transition: all 0.3s;
}
.lightbox-button:hover,
.lightbox-button:focus {
opacity: 1;
-webkit-transform: scale(1.4);
-moz-transform: scale(1.4);
-ms-transform: scale(1.4);
transform: scale(1.4);
}
.lightbox-close {
right: 30px;
top: 30px;
background-image: url("../img/close.png");
}
.lightbox-next {
right: 30px;
top: 48%;
background-image: url("../img/next.png");
}
.lightbox-previous {
left: 30px;
top: 48%;
background-image: url("../img/previous.png");
}
any tips / help is welcomed. thanks
The caption is being loaded by the 'data-caption' attribute in your anchor tag.
Your anchor tags currently look like this:
You need to insert the caption like this:
For your own interest, if you look at the javascript in the source files you'll see these lines:
setCaption: function () {
var caption = $(plugin.current).data('caption');
if(!!caption && caption.length > 0) {
plugin.caption.fadeIn();
$('p', plugin.caption).text(caption);
}else{
plugin.caption.hide();
}
},
The second line says:
var caption = $(plugin.current).data('caption');
This is setting the caption to whatever text you have in the data-caption field. If it said .data('title'), then you would use data-title = "my caption"
Hope that helps.
Need more code to check I would say but you do have
.lightbox-caption {
display: none;
}
This would usually hide this class. Maybe try and remove display:none or change to block or inline etc?
Related
I can not click on that anchor. I try a couple of possible solutions such as adding another anchor or div inside and outside that anchor, adding a z-index and position.
edit: I've added the full code and I realize that z-index must solve the problem. However, I could not find where and how to use z-index.
#import url('https://fonts.googleapis.com/css2?family=Noto+Sans+JP:wght#900&display=swap');
#import url('https://fonts.googleapis.com/css2?family=Catamaran:wght#100&display=swap');
* {
scroll-behavior: smooth;
text-decoration: none;
}
div, section {
margin: 0;
padding: 0;
}
body {
margin: 0;
padding: 0;
background-color: #000;
font-family: 'Catamaran', sans-serif;
}
main {
pointer-events: none;
height: 100vh;
width: 100%;
padding: 0;
margin: 0;
position: relative;
z-index: -1;
}
.hi, .name {
font-family: 'Noto Sans JP', sans-serif;
font-size: 170px;
color: #fff;
height: fit-content;
position: absolute;
}
.hi {
top: 2%;
left: 5%;
text-shadow: 1px 1px 15px rgba(0,0,0,0.83);
}
.name {
right: 7%;
top: 18%;
}
.me {
font-family: 'Noto Sans JP', sans-serif;
font-size: 60px;
color: #fff;
height: fit-content;
position: absolute;
bottom: 2%;
left: 5%;
text-shadow: 1px px 15px rgba(0,0,0,0.83);
}
.background-text {
width: fit-content;
background: #12c2e9;
background: -webkit-linear-gradient(to right, #f64f59, #c471ed, #12c2e9);
background: linear-gradient(to right, #f64f59, #c471ed, #12c2e9);
-webkit-background-clip: text;
-webkit-text-fill-color: transparent;
background-clip: text;
color: transparent;
}
.img-me {
position: absolute;
left: 50%;
top: 47%;
transform: translate(-50%, -50%);
z-index: -1;
}
.img-me img {
height: 82vh;
}
.slide-down {
display: inline-block;
position: absolute;
left: 50%;
bottom: 2%;
transform: translateX(-50%);
}
.mouse-btn {
margin: 10px auto;
width: 40px;
height: 80px;
border: 3px solid rgba(122, 122, 124, 0.918);
border-radius: 20px;
display: flex;
}
.mouse-scroll {
width: 20px;
height: 20px;
background: linear-gradient(170deg, rgba(122, 122, 124, 0.918), rgb(123, 124, 124));
border-radius: 50%;
margin: auto;
animation: scrolling13 1.5s linear infinite;
}
#keyframes scrolling13 {
0% {
opacity: 0;
transform: translateY(-20px);
}
75% {
opacity: 1;
transform: translateY(18.5px);
}
80% {
opacity: 0.5;
transform: translateY(18.8px);
}
84% {
opacity: 0.4;
transform: translateY(19px);
}
88% {
opacity: 0.3;
transform: translateY(19.2px);
}
92% {
opacity: 0.2;
transform: translateY(19.4px);
}
95% {
opacity: 0.1;
transform: translateY(19.6px);
}
98% {
opacity: 0;
transform: translateY(19.8px);
}
100% {
opacity: 0;
transform: translateY(20px);
}
}
<main>
<div class="hi">hi</div>
<div class="name background-text">I am<br>Eren</div>
<div class="me">A freelancer<br>developer<br>and a student</div>
<div class="img-me"><img src="img/businessman-chatting-on-phone.png" alt="Young Man Chatting on Phone Illustration"></div>
<a href="https://www.youtube.com/" class="slide-down">
<span class="mouse-btn">
<span class="mouse-scroll"></span>
</span>
</a>
</main>
If you remove those:
pointer-events: none;
z-index: -1;
the link becomes clickable.
pointer-events: none; ignores events. Since the click events are ignored, clicking the anchor element does nothing.
z-index: -1; is placing the main element behind the body element. If you move pointer-events: none; from main to body, the anchor element becomes clickable. The body element was like an invisible wall in front of main. You were clicking the body element, but not anything inside the main element.
It cannot be clicked if it has no text inside, try this:
-First
Delete the existing Anchor Element.
-Second
Add an id attribute that has the value of anchor (or any id name you prefer) to your parent Span Element
-third :
const anchorSpan = document.getElementById("anchor")
anchorSpan.addEventListener("click",()=>{
createAnchorTage().click()
})
function createAnchorTage(){
const anchorElement = document.createElement("a")
anchorElement.href= "https://youtube.com"
return anchorElement
}
hopefully this helps :).
PS: i Tried your code and it clicked ,so it can be clicked without text ,i don't know what's the problem .
I have this image which is inside div with class="image-wrapper". All I am trying to do is:
display .image-wrapper::before while being hovered on image so it works like title of image
also use transform: scale(1.1) on img so it grows little on being hovered
Description of problem from my side
In order to display title inside image (part 1), using ::before, we cannot use it directly on img as they are replaced elements, so I enclosed img with div with class="image-wrapper" and used ::before on div. And it worked fine as I expected. Now for the second part, I am not able to render both property same time. I am kinda confused.
.image-wrapper {
border: 2px solid black;
display: inline-block;
overflow: hidden;
}
.image-wrapper::before {
content: 'Hello';
height: auto;
width: auto;
padding: 4px;
margin-left: 8px;
background: rgba(0, 0, 240, 0.3);
color: white;
font-size: 20px;
position: absolute;
opacity: 0;
}
img {
width: 100%;
}
img:hover {
transform: scale(1.1);
transition: all 0.2s;
cursor: pointer;
}
/*HERE IS THE PROBLEM*/
.image-wrapper:hover::before {
opacity: 1;
}
<div class="image-wrapper">
<img src="https://images.unsplash.com/photo-1624215824600-ed3118b76873?ixid=MnwxMjA3fDB8MHx0b3BpYy1mZWVkfDMwfDZzTVZqVExTa2VRfHxlbnwwfHx8fA%3D%3D&ixlib=rb-1.2.1&auto=format&fit=crop&w=500&q=60">
</div>
It's kind of all there in your code, but the before pseudo element wont show up above its element, unless you give it a higher z-index.
Also this snippet slightly alters the CSS so that what it's looking for is hover on the image-wrapper class both for the Hello and the img scaling.
.image-wrapper {
display: inline-block;
overflow: hidden;
}
.image-wrapper::before {
content: 'Hello';
height: auto;
width: auto;
padding: 4px;
background: pink margin-left: 8px;
background: rgba(0, 0, 240, 0.3);
color: white;
font-size: 20px;
position: absolute;
opacity: 0;
}
img {
width: 100%;
}
.image-wrapper:hover img {
transform: scale(1.1);
transition: all 0.2s;
cursor: pointer;
}
.image-wrapper:hover::before {
opacity: 1;
z-index: 100;
}
<div class="image-wrapper">
<img src="https://images.unsplash.com/photo-1624215824600-ed3118b76873?ixid=MnwxMjA3fDB8MHx0b3BpYy1mZWVkfDMwfDZzTVZqVExTa2VRfHxlbnwwfHx8fA%3D%3D&ixlib=rb-1.2.1&auto=format&fit=crop&w=500&q=60">
</div>
I need the title link to direct to a separate page.
Here is a snippet of my code.
<div class="img-container design" data-category="design">
<h3 class="pro2">Angular JS Sales List <a class="pro1" href="https://github.com/Daniel1836/Angular-JS-Project">Git Hub</a> </h3>
<img src="img/angular.png">
<a class="img-overlay" href="/portfolio/index2.html"></a>
<div class="img-overlay-text">
I've tried many combinations of ordering the code, but the link on the bottom is the one that both links redirect to, as if it is spanning the entire image length.
Thanks
Edit
Here is the relevant CSS. The code is not my own.
.img-container {
position: relative;
width: 30%;
margin: 10px;
height: auto; }
.img-container img {
border-radius: 10px; }
#media screen and (max-width: 760px) {
.img-container {
width: 100%; } }
.img-overlay {
position: absolute;
width: 100%;
height: 100%;
top: 0;
left: 0;
background: rgba(229, 46, 45, 0.3);
border-radius: 10px;
outline: 1px solid #fff;
outline-offset: -15px;
cursor: pointer;
-webkit-transition: all .3s ease-out;
-o-transition: all .3s ease-out;
transition: all .3s ease-out;
opacity: 0; }
.img-overlay:hover {
opacity: 1; }
.img-overlay-text {
position: inherit;
top: 50%;
left: 50%;
-webkit-transform: translate(-50%, -50%);
-ms-transform: translate(-50%, -50%);
transform: translate(-50%, -50%);
color: #fff;
text-align: center; }
.img-overlay-text h3 {
margin: 0; }
.img-overlay-text p {
color: #fff; }
The second link should be like this:
<a class="img-overlay" href="/portfolio/index2.html">
<img src="img/angular.png" />
</a>
This question already has answers here:
How do I give text or an image a transparent background using CSS?
(29 answers)
Opacity of background-color, but not the text [duplicate]
(5 answers)
Closed 4 years ago.
I find myself having problems in controlling the opacity of my items inside my container. The container should be the only one that is transparent but unfortunately all the items inside my container began to go transparent even though I already establish opacity: 1; to them.
Here is my code...
HTML
<!DOCTYPE html>
<html>
<head>
<title>Dino-Jump</title>
<link rel="stylesheet" type="text/css" href="style.css">
<meta name = "viewport" content = "width=device-width, initial-scale=1.0">
</head>
<body class = "bg">
<div id = container>
<img src="Pics/user.jpg" id = "user">
<form action = "action-login">
<div id = "login-box">
<h1 class = "label1">Login</h1>
<div class = "textbox">
<i class = "fa fa-user" aria-hidden = "true"></i>
<input type="text" name="uname" placeholder="Username" required = "true">
</div>
<div class = "textbox">
<i class = "fa fa-lock" aria-hidden = "true"></i>
<input type="password" name="pword" placeholder="Password" required = "true">
</div>
<input class = "btn" type = "button" name = "login" value = "Login">
<a id = "forget" href=""> Forget Password </a>
<a id = "reg" href=""> Register </a>
</form>
</div>
</div>
<img src="Pics/title.png" id="game-title">
<div class = "footer">
<p>© Copyrights Dino-Jump ZRH.Group 10.20.20.18.2.37</p>
</div>
</body>
</html>
CSS
/**Style**/
#import "https://stackpath.bootstrapcdn.com/font-awesome/4.7.0/css/font-awesome.min.css";
#media screen and (min-width:768){
.bg{
width: 100%;
margin: 0 auto;
padding: 0 auto;
display: block;
font-family: sans-serif;
background-image: url("Pics/bg.jpg");
background-repeat: no-repeat;
background-size: 100%;
}
img{
width: 100%;
}
}
/**bofy**/
.bg{
margin: 0 auto;
padding: 0 auto;
font-family: sans-serif;
background-image: url("Pics/bg03.jpg");
background-repeat: no-repeat;
background-size: 100%;
}
#user{
opacity: 1;
background-image: url("Pics/user.jpg");
width: 135px;
height: 135px;
margin: 0 auto;
padding: 0 auto;
border-radius: 50%;
border: 4px solid #ffbd04;
position: relative;
top: 50%;
left: 50%;
transform: translate(-50%, -50%);
z-index: 10;
}
#container{
opacity: 0.5;
margin: 0 auto;
padding: 0 auto;
position: absolute;
top: 50%;
left: 50%;
transform: translate(-50%,-50%);
width: 380px;
height: 480px;
background: #000;
border: 4px solid #ffbd04;
border-radius: 20px;
}
#login-box{
opacity: 1;
width: 280px;
position: absolute;
top: 50%;
left: 50%;
transform: translate(-50%,-50%);
color: #fff;
}
#login-box h1{
float: left;
font-size: 40px;
border-bottom: 4px solid #ffbd04;
margin-bottom: 50px;
padding: 13px 0;
}
.textbox{
width: 100%;
overflow: hidden;
font-size: 20px;
padding: 8px 0;
margin: 8px 0;
border-bottom: 1px solid #ffbd04;
}
.texbox i{
width: 26px;
float: left;
text-align: center;
}
.textbox input{
border: none;
outline: none;
background: none;
color: #fff;
font-size: 18px;
width: 80%;
float: left;
margin: 0 10px;
}
::placeholder {
color: #fff;
}
[placeholder]:focus::-webkit-input-placeholder {
transition: text-indent 0.3s 0.3s ease;
text-indent: -100%;
opacity: 1;
}
.btn{
width: 100%;
background: none;
border: 2px solid #ffbd04;
border-radius: 10px;
color: #fff;
padding: 5px;
font-size: 18px;
margin: 12px;
transition: .6s;
overflow: hidden;
}
.btn:focus{
outline: none;
}
.btn:before{
content: '';
display: block;
position: absolute;
background: rgba(255,255,255,.5);
opacity: 0.5;
filter: blur(30px);
transform: translateX(-130px) skewX(-15deg);
}
.btn:after{
content: '';
display: block;
position: absolute;
background: rgba(255,255,255,.5);
opacity: 0;
filter: blur(30px);
transform: translate(-100px) scaleX(-15deg);
}
.btn:hover{
background: #ffbd04;
cursor: pointer;
}
.btn:hover:before{
transform: translateX(300px) skewX(-15deg);
opacity: 0.6;
transition: 0.7s;
}
.btn:hover:after{
transform: translateX(300px) skewX(-15deg);
opacity: 1;
transition: 0.7s;
}
/**Footer**/
.footer{
position: fixed;
left: 0;
bottom: 0;
width: 100%;
background-color: #000;
color: #fff;
text-align: left;
font-size: 8px;
}
#game-title{
width: 130px;
height: 40px;
position: absolute;
top: 91%;
left: 50%;
transform: translate(-50%,-50%);
}
#forget{
text-decoration: none;
position: absolute;
top: 110%;
left: 50%;
transform: translate(-50%, -50%);
color: #ffbd04;
font-size: 12px;
font-family: sans-serif;
}
#reg{
text-decoration: none;
position: absolute;
top: 110%;
left: 50%;
transform: translate(-50%, -190%);
color: #ffbd04;
font-size: 12px;
font-family: sans-serif;
}
Sorry long post and thank you in advance.
The approach is wrong sir. It's child element's default behavior. You can't set opacity:1 to the child element once you set it to the parent element.
You have so many ways to achieve this. But since you are using a background color and looking for the opacity I suggest the easiest way that use background:rgba(0,0,0,0.5).This stands that the background color is #333 with the opacity of 0.5.
Learn more about rgba() here.
#container{
/*opacity: 0.5;*/ //remove this line
margin: 0 auto;
padding: 0 auto;
position: absolute;
top: 50%;
left: 50%;
transform: translate(-50%,-50%);
width: 380px;
height: 480px;
/*background: #000;*/ //remove this line
border: 4px solid #ffbd04;
border-radius: 20px;
background:(0,0,0,0.5); //newly added line
}
You have given opacity:0.5 to container class and opacity:1 to child class. Instead of setting opacity to parent class use background color in rgba format to container class and remove opacity
background: rgba(0, 0, 0, 0.5);
If you use opacity to parent class then child class does not have effect even if you set high opacity to child.
I was able to get some result by using the !important keyword.
#login-box{
opacity: 1 !important;
width: 280px;
position: absolute;
top: 50%;
left: 50%;
transform: translate(-50%,-50%);
background: #fff !important;
}
You can't see the text, but you might able to get what you want from there.
I am trying to build a progress bar as seen often within checkouts.
The problem is, that the borders between the arrows are transparent and the whole thing should be responsive.
I got it this far:
http://codepen.io/MrBambule/pen/rVBeoz
But I can't figure out how to get the items of the bar to span the whole width of the parent container (red border in the pen) and stay responsive.
I think I could figure it out with JS but I'd rather have a CSS solution.
Help would be much appreciated.
HTML
<ul class="progress-nav">
<li class="active">
<span>1. FOO</span>
</li>
<li>
<span>2. BAR</span>
</li>
<li>
<span>3. BAZ</span>
</li>
</ul>
CSS
$bar-color: rgba(255, 255, 255, 0.2);
$bar-active-color: rgba(255, 255, 255, 0.6);
$arrow-size: 22px;
body {
background: linear-gradient(left, #803689, #5eb6e4);
}
.progress-nav {
position: relative;
font-size: 0;
margin: 100px auto;
width: 80%;
max-width: 900px;
// dummy border to display the width problem
border: 1px solid red;
li {
position: relative;
color: #fff;
font-size: 12px;
display: inline-block;
width: 20%;
margin-right: 48px;
list-style: none;
background: $bar-color;
padding: $arrow-size 0;
transition: background .5s, color .5s;
span {
position: absolute;
width: 100%;
top: 50%;
left: 50%;
transform: translateX(-33px) translateY(-35%);
}
&:before,
&:after {
content: '';
position: absolute;
display: block;
top: 0;
transition: all .5s;
}
&:before {
border: $arrow-size solid $bar-color;
border-left-color: transparent;
left: -$arrow-size*2;
}
&:after {
border: $arrow-size solid transparent;
border-left-color: $bar-color;
right: -$arrow-size*2;
}
&:first-child:before {
border: none;
width: $arrow-size*2;
height: $arrow-size*2;
background: $bar-color;
border-radius: 4px 0 0 4px;
}
&:last-child:after {
border: none;
right: -$arrow-size;
width: $arrow-size;
height: $arrow-size*2;
background: $bar-color;
border-radius: 0 4px 4px 0;
}
&.active,
&:hover {
background: $bar-active-color;
color: #000;
&:before {
border-color: $bar-active-color;
border-left-color: transparent;
}
&:after {
border-left-color: $bar-active-color;
}
&:first-child:before,
&:last-child:after {
background: $bar-active-color;
}
}
}
}
you could use something like:
.wrap {
width: 100%;
height: 30px;
z-index:-2;white-space: nowrap;
overflow:hidden;
}
.wrap div:first-child{margin-left:-2%;}
.progress {
margin:0;
margin-left:0.5%;
height: 30px;
width: 25%;
position: relative;
display: inline-block;
text-align: center;
line-height: 30px;
transition: all 0.8s;
}
.progress:before,
.progress:after {
content: "";
position: absolute;
transition: all 0.8s;
z-index:-1;
}
.progress:before {
height: 50%;
width: 100%;
top: 0;
left: 0;
background: rgba(0, 0, 0, 0.2);
-webkit-transform: skew(45deg);
-moz-transform: skew(45deg);
transform: skew(45deg);
}
.progress:after {
height: 50%;
width: 100%;
top: 50%;
left: 0;
background: rgba(0, 0, 0, 0.2);
-webkit-transform: skew(-45deg);
-moz-transform: skew(-45deg);
transform: skew(-45deg);
}
.progress:hover:before,
.progress:hover:after {
background: tomato;
}
<div class="wrap">
<div class="progress">
simple
</div>
<div class="progress">
as
</div>
<div class="progress">
complex
</div>
<div class="progress">
Web Development
</div>
</div>
which is responsive to the width of the screen.
It makes use of the transform:skew property for the middle bars, and a small border hack for the two far elements. This results in the output shown below:
Result
NOTE
If you are creating these dynamically (and want them all along the same line), then you will need to alter the width stated in the first css rule (currently set to 23%).