Width of gradient increases on zoom out? - html

I have created a div that uses a linear gradient. When I zoom out (and or zoom in) my gradient shrinks and grows depending on how much I zoom out or in, I set a specific width to try to stop this. It didn't work.
body{
background: linear-gradient(200deg,#aebcbf -10%,#6e7774 110%,#0a0809 1000%);
background-repeat:no-repeat
}
img {
animation-name: rotate;
animation-iteration-count: infinite;
animation-duration:1s;
animation-direction: reverse;
animation-timing-function: ease-in;
animation-play-state: playing;
float: left;
opacity:0.5;
border-radius:90%;
}
h1{
font-size:20px;
font-family: monospace;
font-variant-caps:titling-caps;
text-align:center;
text-decoration-style: wavy;
text-shadow: 2px 2px #FFFFFF;
}
#keyframes rotate {
from {
transform: rotate(0deg);
}
to {
transform: rotate(360deg);
}
}
#css-gradient {
background: linear-gradient(blue, white);
width:47%;
border-style:outset;
background-repeat:no-repeat
}
<div id="css-gradient">
<img src="http://i.imgur.com/gQioYac.png" draggable="false">
<img src="http://i.imgur.com/gQioYac.png" draggable="false">
<img src="http://i.imgur.com/gQioYac.png" draggable="false">
<img src="http://i.imgur.com/gQioYac.png" draggable="false">
<img src="http://i.imgur.com/gQioYac.png" draggable="false">
<div style="clear: left;"></div>
<input type=color style="width:15px;height:100px;position:absolute;left:635px;top:8px;height:125px">
<h1 title="If successful this will be in a white box">Hover over me!</h1>
<hr style="width:300px;position:relative;top:-5px;border-style:double">
</div>
Here's a JSFiddle (https://jsfiddle.net/ffksjqp2/1/)

Im not sur I understood your problem. Do you mean a zoom in / zoom out with your browser ?
Anyway you can try this with your css-gradient class :
#css-gradient {
background: linear-gradient(blue, white);
background-attachment: fixed;
width:47%;
border-style:outset;
background-repeat:no-repeat
}

Related

why is my container not in the center of the screen, even though I have changed the margins (left & right) to auto?

hey I am new to programming and I'm trying the css vertical text slide animator feature, when the feature runs smoothly the text turns out to be disproportionate (not in the middle of the screen) even though I've added margins (right & left) to auto
#keyframes animate{
0%,100%{
top:0;
}
20%{
top:0px;
}
25%{
top:-50px;
}
45%{
top:-50px;
}
50%{
top:-100px;
}
70%{
top:-100px;
}
75%{
top:-150px;
}
95%{
top:-150px;
}
}
<div class="container " style="margin-left: auto; margin-right:auto">
<h1 class="display-4 w3-center w3-animate-right" >Hi I'm Raffiel</h1>
<div class="outer " style="display: block; position:relative;">
<h1 style="font-size: 45px ;">I am,
<div class="inner" style="position:absolute; border:0px solid #ddd; height:50px; line-height:50px; font-size:45px; text-transform:uppercase; overflow:hidden; display:inline-block; text-align: left; font-weight: 400;">
<span style="animation:animate 10s ease infinite; position:relative;color:#e58e26; text-align: left;">
Graphic Designer<br>
Digital Marketer<br>
Video Editor<br>
Web Designer<br>
</span>
</div>
</h1>
</div>
</div>
strong text
Basically it should have been position:relative in order to take "space" and be included in the text-align:center. But you still need to fine tune this example.
#keyframes animate {
0%,
100% {
top: 0;
}
20% {
top: 0px;
}
25% {
top: -50px;
}
45% {
top: -50px;
}
50% {
top: -100px;
}
70% {
top: -100px;
}
75% {
top: -150px;
}
95% {
top: -150px;
}
}
<link href="https://cdn.jsdelivr.net/npm/bootstrap#5.2.0/dist/css/bootstrap.min.css" rel="stylesheet" integrity="sha384-gH2yIJqKdNHPEq0n4Mqa/HGKIhSkIHeL5AyhkYV8i59U5AR6csBvApHHNl/vI1Bx" crossorigin="anonymous">
<div class="container" style="text-align:center">
<h1 class="display-4 w3-center w3-animate-right">Hi I'm Raffiel</h1>
<div class="outer">
<h1 style="font-size: 45px ;height:50px; line-height:50px ">I am,
<div class="inner" style="position:relative; border:0px solid #ddd; height:45px; line-height 45px; font-size:45px; text-transform:uppercase; overflow:hidden; display:inline-block; text-align: left; font-weight: 400; ">
<span style="animation:animate 10s ease infinite; position:relative;color:#e58e26; ">
Graphic Designer<br>
Digital Marketer<br>
Video Editor<br>
Web Designer<br>
</span>
</div>
</h1>
</div>
</div>
try this
#keyframes animate{
0%,100%{
top:0;
}
20%{
top:0px;
}
25%{
top:-50px;
}
45%{
top:-50px;
}
50%{
top:-100px;
}
70%{
top:-100px;
}
75%{
top:-150px;
}
95%{
top:-150px;
}
}
<div class="container " style=" width:100%; margin: auto;">
<h1 class="display-4 w3-center w3-animate-right" style="text-align:center;" >Hi I'm Raffiel</h1>
<div class="outer " style="display: block; text-align:center;">
<h1 style="font-size: 45px;">I am,
<div class="inner" style=" border:0px solid #ddd; height:50px; line-height:50px; font-size:45px; text-transform:uppercase; overflow:hidden; display:inline-block; text-align:left; font-weight: 400;">
<span style="animation:animate 10s ease infinite; position:relative;color:#e58e26; ">
Graphic Designer<br>
Digital Marketer<br>
Video Editor<br>
Web Designer<br>
</span>
</div>
</h1>
</div>
</div>

CSS Animation that Allows Image to Cover All Content on Screen

I am trying to figure out how I can write a CSS animation that allows an image (id: slam) to suddenly appear on screen and cover all of the content without displacing any of the text. So far, this is what I have:
HTML:
body{
height: 100%;
}
div{
overflow: auto;
text-align: center;
}
#-webkit-keyframes slam-animation {
0% {
opacity: 0;
-webkit-transform: scale(10);
}
100% {
opacity: 1;
-webkit-transform: rotate(-30deg) scale(1);
}
}
#slam {
-webkit-animation-name: slam-animation;
-webkit-animation-duration: 1s;
-webkit-animation-direction: normal;
-webkit-animation-timing-function: linear;
-webkit-animation-fill-mode: forwards;
}
<body>
<img id="slam" src="assets/images/Undesirable.jpg" alt = "undesirable">
<header>
<h1>Text</h1>
</header>
<div class="main_game">
<p>Stuff</p>
<div class = "col-xs-2">
</div>
<div class = "left_box col-xs-4">
<p>Stuff</p>
</div>
<div class = "right_box col-xs-4">
<p>Stuff</p>
</div>
<div class = "col-xs-2">
</div>
</div>
</body>
Use position:absolute to your image.
Using absolute position the element is removed from the normal document flow; no space is created for the element in the page layout i.e. it will not affect the position of other elements.
Reference Link to understand position absolute
Stack Snippet
body {
height: 100%;
}
.main_game div {
text-align: center;
}
.main {
position: relative;
}
#-webkit-keyframes slam-animation {
0% {
opacity: 0;
-webkit-transform: scale(10);
}
100% {
opacity: 1;
-webkit-transform: rotate(-30deg) scale(1);
}
}
img#slam {
position: absolute;
top: 0;
left: 0;
}
#slam {
-webkit-animation-name: slam-animation;
-webkit-animation-duration: 1s;
-webkit-animation-direction: normal;
-webkit-animation-timing-function: linear;
-webkit-animation-fill-mode: forwards;
}
<div class="main">
<img id="slam" src="http://via.placeholder.com/350x350" alt="undesirable">
<header>
<h1>Text</h1>
</header>
<div class="main_game">
<p>Stuff</p>
<div class="col-xs-2">
</div>
<div class="left_box col-xs-4">
<p>Stuff</p>
</div>
<div class="right_box col-xs-4">
<p>Stuff</p>
</div>
<div class="col-xs-2">
</div>
</div>
</div>

Is there a way to modify this without JS or Jquery?

I found this image carousel here I'm wondering if there is a way to make it not auto scroll but instead have navigation buttons, as well as make it responsive. Is there a way to do this but still keep it Css only?
<h1>css3 carousel</h1>
<div class="carousel">
<div class="holder">
<img src="http://fakeimg.pl/200x100" alt="" />
<img src="http://fakeimg.pl/300x200" alt="" />
<img src="http://fakeimg.pl/400x300" alt="" />
<img src="http://fakeimg.pl/200x100" alt="" />
<img src="http://fakeimg.pl/500x400" alt="" />
<img src="http://fakeimg.pl/210x105" alt="" />
<img src="http://fakeimg.pl/200x100" alt="" />
<img src="http://fakeimg.pl/250x150" alt="" />
<img src="http://fakeimg.pl/200x100" alt="" />
<img src="http://fakeimg.pl/200x100" alt="" />
<img src="http://fakeimg.pl/200x100" alt="" />
<img src="http://fakeimg.pl/200x100" alt="" />
</div>
</div>
#import url(http://fonts.googleapis.com/css?family=PT+Sans);
body {
font-family: 'PT Sans', Arial, Verdana;
background-color: #eee;
}
h1 {
text-align: center;
font-size: 48px;
text-transform: uppercase;
letter-spacing: 3px;
color: #222;
}
img {
display: inline-block;
width: 200px;
height: 100px;
}
.carousel {
width: 830px;
height: 120px;
overflow: hidden;
padding: 8px;
box-sizing: border-box;
border: 2px solid #999;
box-shadow: 0 0 4px #000;
margin: 0 auto;
border-radius: 5px;
}
.holder {
animation: carousel 25s linear infinite;
white-space: nowrap;
will-change: transform;
&:hover {
animation-play-state: paused;
}
}
#keyframes carousel {
0% {
transform: translateX(0);
}
50% {
transform: translateX(-100%);
}
100% {
transform: translateX(0);
}
}
Changing your CSS slightly will add a basic hover functionality to start the slider form a stopped position.
.holder {
animation: carousel 25s linear;
white-space: nowrap;
will-change: transform;
animation-play-state: paused;
&:hover {
animation-play-state: running;
}
}
Making it responsive would be easy with 'media queries'.
But considering you want to make it responsive then you will need 'click events' to make it work on mobile (as mobile has no hover functionality). CSS can't do click events so you will need javascript or jQuery. But this should be fairly straight forward, you'll only be changing minor CSS with a simple click event. However considering the endless amount of free and basic carousel plugins out there, I would opt for one of them. What you have here seems to be a demonstration on CSS animations, and without some kind of javascript, you will always be limited when it comes to CSS animation control.

Button hover on a changing background

I am making a website for a friend but since I'm still a beginner at this I'm not sure how to proceed. I'm making a simple intro page with his name and an enter button. The enter button has a hover function that when you hover your mouse over it it changes color, meanwhile I have a background div loop that iterates through 5 different backgrounds. My button and its hover function work fine on the first background picture, but once it changes the hover function no longer works until it comes back to that very first picture.
The background changing is a css code I found here on stack while I made everything else.
Here's My Code with what I'm working with.
Any ideas why the button hover isn't working on all the backgrounds?
HTML
<body class="intro-body">
<div id="background-change">
<div class="background-image image1">
<h1 class="intro-title">Name Here</h1>
<p class="intro-button intro-button-hover">Enter</p>
</div>
<div class="background-image image2">
<h1 class="intro-title">Name Here</h1>
<p class="intro-button intro-button-hover">Enter</p>
</div>
<div class="background-image image3">
<h1 class="intro-title">Name Here</h1>
<p class="intro-button intro-button-hover">Enter</p>
</div>
<div class="background-image image4">
<h1 class="intro-title">Name Here</h1>
<p class="intro-button intro-button-hover">Enter</p>
</div>
<div class="background-image image5">
<h1 class="intro-title">Name Here</h1>
<p class="intro-button intro-button-hover">Enter</p>
</div>
</div>
</body>
CSS
.intro-body {
text-align: center;
background-repeat: no-repeat;
background-position: center;
}
.intro-title {
padding-top: 20vh;
padding-bottom: 5vh;
font-size: 650%;
text-transform: uppercase;
text-align: center;
color: white;
letter-spacing: 5px;
text-shadow: 2px 2px black;
}
.intro-button {
border: solid;
color: white;
padding: 20px 45px;
display: inline-block;
letter-spacing: 2px;
text-align: center;
text-transform: uppercase;
cursor: pointer;
}
p.intro-button-hover:hover {
background-color: white;
opacity: 0.85;
padding: 23px 48px;
letter-spacing: 2px;
text-align: center;
text-transform: uppercase;
color: black;
border: unset;
cursor: pointer;
}
.background-image {
-webkit-background-size: cover;
-moz-background-size: cover;
-o-background-size: cover;
background-size: cover;
position: absolute;
top: 0;
left: 0;
height: 100%;
width: 100%;
}
.image1{
background: url("http://placekitten.com/1200/1200") no-repeat center fixed;
}
.image2{
background: url("http://placekitten.com/1200/1300") no-repeat center fixed;
}
.image3{
background: url("http://placekitten.com/1300/1200") no-repeat center fixed;
}
.image4{
background: url("http://placekitten.com/1300/1300") no-repeat center fixed;
}
.image5{
background: url("http://placekitten.com/1300/1400") no-repeat center fixed;
}
#keyframes backgroundchangeFadeInOut {
0% {
opacity:1;
}
17% {
opacity:1;
}
25% {
opacity:0;
}
92% {
opacity:0;
}
100% {
opacity:1;
}
}
#-webkit-keyframes backgroundchangeFadeInOut {
0% {
opacity:1;
}
17% {
opacity:1;
}
25% {
opacity:0;
}
92% {
opacity:0;
}
100% {
opacity:1;
}
}
#background-change div:nth-of-type(1) {
animation-delay: 20s;
-webkit-animation-delay: 20s;
}
#background-change div:nth-of-type(2) {
animation-delay: 15s;
-webkit-animation-delay: 15s;
}
#background-change div:nth-of-type(3) {
animation-delay: 10s;
-webkit-animation-delay: 10s;
}
#background-change div:nth-of-type(4) {
animation-delay: 5s;
-webkit-animation-delay: 5s;
}
#background-change div:nth-of-type(5) {
animation-delay: 0s;
-webkit-animation-delay: 0s;
}
#background-change div {
animation-name: backgroundchangeFadeInOut;
animation-timing-function: ease-in-out;
animation-iteration-count: infinite;
animation-duration: 25s;
-webkit-animation-name: backgroundchangeFadeInOut;
-webkit-animation-timing-function: ease-in-out;
-webkit-animation-iteration-count: infinite;
-webkit-animation-duration: 25s;
}
Just update with the following code, I have just added internal js.
<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.12.4/jquery.min.js"></script>
<script>
$(document).ready(function(){
$("p").mouseover(function(){
$("p").css("background-color", "white");
});
$("p").mouseout(function(){
$("p").css("background-color", "");
$("p").css("color", "black");
});
});
And remove the properties with '//' in the css:
p.intro-button-hover:hover {
// background-color: #fff;
//opacity: 0.4;
padding: 23px 48px;
letter-spacing: 2px;
text-align: center;
text-transform: uppercase;
//color: black;
border: unset;
cursor: pointer;
}
Quickly looking at this, the reason for it is that you actually have 5 different buttons fading in and out, which messes things up.
Do something like this (pseudocode)
<body class="intro-body">
<div id="callout">
<h1 class="intro-title">Name Here</h1>
<button class="intro-button intro-button-hover">Enter</button>
</div>
<div id="background-change">
<div class="background-image image1"></div>
<div class="background-image image2"></div>
<div class="background-image image3"></div>
<div class="background-image image4"></div>
<div class="background-image image5"></div>
</div>
</body>
Naturally position the callout section over the background image and you're good to go.
I have gone through your code and tried debugging the problem. The problem is mostly from your animation code. Try rewriting your animation code. I have tested it removing the animation code, to check if the hover is working properly or not, and it works fine. There is also a bug with your animation code which makes the Enter button disappear for a while after the first animation iteration and appear again after few seconds.
If possible try using JQuery, as it makes your job easier for using animations. For example, can simply use fadeIn(); and fadeOut(); functions for the animation you have been doing in your CSS animation code.

Black transparent overlay on image

I'm trying to get a light black overlay on the image when you hover on it (like the text) sorry I'm new to css and HTML!
help would be appreciated
HTML
<div id="con">
<div id="box1">
<p id="text1">
DESTINATIONS
</p>
</p>
<p id="text2">
AMALFI<BR>SORRENTO<BR>POSITANO</a>
</p>
<p id="text3">
THINGS TO DO
</p>
</p>
<p id="text4">
TOURS<BR>MUSUEMS<BR>SHOPPING</a>
</p>
</div>
css
#con {
width:1024px;
height:670px;
background-color: #161717;
}
#box1 {
float: left;
font-size: 25px;
width: 388px;
height: 477px;
background-image: url(media/trying1.png);
background-size: cover;
margin-left: 120px;
margin-top: 90px;
}
#text1 {
z-index:100;
color:white;
font-size:30px;
text-align: center;
margin-top:80px;
line-height:55px;
opacity: 0;
transition: all 0.5s;
}
#box1:hover #text1 {
opacity: 1;
}
This can be done with :before or :after
#box1{
position:relative;
}
#box1:before{
content:'';
position:absolute;
top:0;
left:0;
right:0;
bottom:0;
background:black;
opacity:0;
z-index:0;
}
#box1:hover:before{
opacity:.6;
transition: all 0.5s;
}
#box1 > *{
position:relative;
z-index:1;
}
http://jsfiddle.net/4bo4zju7/3/
CS3 is great! You no longer need JS for simple rollover effects. Gopalraju's above code should work and so does my example below. You can have a fiddle with it and use the code as you see fit.
The parent div, has a black page background, and the imgdiv changes everything inside it to a opacity by 50% on the mouse rolling over the div. In this case the image is inside the div.
There are a few ways of doing this. This is just another one to ad into the mix. Good luck.
.parentdiv {
background-color:#000;
height:100%;
width:100%;
}
.imgdiv {
padding:30px;
}
.imgdiv a{
opacity: 1;
filter: alpha(opacity=100);
-webkit-transition: opacity 0.5s linear;
}
.imgdiv a:hover {
opacity: 0.5;
filter: alpha(opacity=50);
-webkit-transition: opacity 0.5s linear;
}
<div class="parentdiv">
<div class="imgdiv">
<a href="http://www.domain.com.au/link.html">
<img src="http://placehold.it/350x150" alt="image" height="150" width="350">
</a>
</div>
</div>