My animation repeats the movement several times in css - html

I have an animation that when I hover over the div right at the beginning of the element it repeats all the time, it gets stuck repeating itself.
#servicios {
text-align : center;
}
#servicios ul li {
list-style : none;
}
.grid-container {
display : grid;
grid-template-columns : auto auto auto;
column-gap : 50px;
justify-content : space-around;
}
.grid-item {
font-family : system-ui, -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, Ubuntu, Cantarell, 'Open Sans', 'Helvetica Neue', sans-serif;
padding : 20px;
font-size : 30px;
text-align : center;
margin-top : 30px;
width : 250px;
border-radius : 5px;
box-shadow : rgba(60, 64, 67, 0.3) 0px 1px 2px 0px, rgba(60, 64, 67, 0.15) 0px 2px 6px 2px;
}
.grid-item:hover {
animation : desplazamiento 700ms ease-in;
animation-fill-mode : forwards;
/* transform-origin: top left; */
}
.grid-text:active {
margin-top : 20px;
}
#keyframes desplazamiento {
0% { position: relative; top: 0px; }
100% { position: relative; top: 25px; }
}
<section id="servicios">
<h2>Servicios</h2>
<div class="grid-container">
<div class="grid-item">
<span class="grid-text">Diseño web</span>
</div>
<div class="grid-item">
<span class="grid-text">Hosting Web</span>
</div>
<div class="grid-item">
<span class="grid-text">Servicios de consultoría en línea</span>
</div>
</div>
</section>
I have tried several ways but I do not understand why it stays stuck
And sorry for filling in the text in this question, it's that stack doesn't let me post because it says that there is only code in the question, that there is more code than text

This is happening because the element you are hovering over moves out from under your pointer, thus no longer being hovered. You'll want to have a container that doesn't move, and apply the transition to the child (grid-item) of the hover pseudo class for the container.
Note that I've moved margin-top to the grid-item-container and changed the box-sizing for grid-item. I have used transition in lieu of the animation and used transform to move the element. Transition should be used for simple animations, where possible. I've used transform instead of animating the position, because it does not cause reflow, which can affect performance and page layout.
#servicios {
text-align : center;
}
#servicios ul li {
list-style : none;
}
.grid-container {
display : grid;
grid-template-columns : auto auto auto;
column-gap : 50px;
justify-content : space-around;
}
.grid-item {
font-family : system-ui, -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, Ubuntu, Cantarell, 'Open Sans', 'Helvetica Neue', sans-serif;
padding : 20px;
font-size : 30px;
text-align : center;
margin-top : 30px;
width : 250px;
height: 100%;
box-sizing: border-box;
border-radius : 5px;
box-shadow : rgba(60, 64, 67, 0.3) 0px 1px 2px 0px, rgba(60, 64, 67, 0.15) 0px 2px 6px 2px;
}
.grid-item-container:hover .grid-item {
transform: translateY(25px);
transition: transform .7s;
cursor: pointer;
}
.grid-text:active {
margin-top : 20px;
}
.grid-item-container {
margin-top: 30px;
}
HTML
<section id="servicios">
<h2>Servicios</h2>
<div class="grid-container">
<div class="grid-item-container">
<div class="grid-item">
<span class="grid-text">Diseño web</span>
</div>
</div>
<div class="grid-item-container">
<div class="grid-item">
<span class="grid-text">Hosting Web</span>
</div>
</div>
<div class="grid-item-container">
<div class="grid-item">
<span class="grid-text">Servicios de consultoría en línea</span>
</div>
</div>
</div>
</section>

Related

there is an empty space next to the banner

https://ibb.co/tL337vV
Look closely at the top right corner of the page you will see there is an empty space that I can't get rid of.
this only appears on actual phones and tablets not on desktop even if squeeze the browser.
<div class="banner">
<div class="banner-content">
<div class="banner-text">
<h1 class="welcoming"></h1>
</div>
</div>
</div>
*{
box-sizing: border-box;
padding: 0px;
margin: 0px;
}
html, body {
margin: 0;
}
body {
background-color: rgb(255, 253, 250);
}
/*header*/
.banner {
background-color: rgb(153, 217, 234);
max-height: 200px;
}
.banner-content {
padding: 20px;
align-items: center;
}
.banner-text {
flex-grow: 1;
line-height: 1.4;
}
.welcoming {
color: aliceblue;
text-align: center;
font-weight: bold;
font-size: 120px;
font-family: 'Lucida Sans', 'Lucida Sans Regular', 'Lucida Grande', 'Lucida Sans Unicode', Geneva, Verdana, sans-serif ;
text-transform: uppercase;
}
also you can see that the search bar isn't aligned properly, any suggestions?
<div class="wrapper">
<div class="search-input">
<a href="" target="_blank" hidden></a>
<input type="text" class="search-box" placeholder="Pick a topic, person, something">
<div class="autocom-box">
<!-- here list are inserted from javascript -->
</div>
<div class="icon"><i class="fas fa-search"></i></div>
</div>
</div>
.wrapper{
max-width: 810px;
margin: 150px auto;
}
.wrapper .search-input {
text-align: center;
margin: 15px;
}
.wrapper .search-input{
background: #fff;
width: 100%;
border-radius: 5px;
position: relative;
box-shadow: 0px 1px 5px 3px rgba(0,0,0,0.12);
font-family: 'Poppins', sans-serif;
}
Looks like something is causing an overflow on the page. One trick that I often use in such situation is going into dev tools and adding this style rule:
* {
background-color: rgba(2,2,240, 0.1) !important;
}
It lets you see every elements position and check which one is causing an overflow
Remove width: 100%; from your .wrapper .search-input class
Edit: I'm assuming you wanted to target your input field when applying the width: 100%;, so you could add this to your CSS:
.wrapper .search-box {
width: 100%;
}

Image Box-Shadow Positioning

I want my screen to have this box-shadow property so there's a box with all the content inside of the screen. I also want to place an image as the landing section and the image will pulsate then fade into the rest of the web page. I cannot get the image to center in the box I have created.
Not sure how to do this
body {
font-family: 'Lucida Sans', 'Lucida Sans Regular', 'Lucida Grande', 'Lucida Sans Unicode', Geneva, Verdana, sans-serif;
margin: 0;
background: #eee;
height: auto;
}
* {
-webkit-box-sizing: border-box;
box-sizing: border-box;
}
main {
max-width: 900px;
margin: auto;
box-shadow: 30px 0px 40px rgba(0, 0, 0, 0.1), -30px 0px 40px rgba(0, 0, 0, 0.2);
}
#landing {
background: white;
}
i {
background: rgb(0, 0, 0);
border-radius: 20px;
font-size: 25px;
position: relative;
margin-right: 10px;
border-radius: 50%;
display: inline-block;
padding: 10px;
}
img {
display: block;
}
<body>
<main>
<!--Landing Page-->
<div id="landing">
<div id="landing-image">
<i><img src="/img/diamond"></i>
</div>
</div>
<!--Navigation Page-->
<section id="navigation">
</section>
<!--Developer Page-->
<section id="developer">
</section>
<!--Projects Page-->
<section id="projects">
</section>
<!--Contact Page-->
<section id="contact">
</section>
</main>
</body>
I want the diamond and the circle around it to be smaller and in the middle of the box on the screen.
Add this CSS to align the image and the circle to the center.
#landing-image {
text-align: center;
}
For reducing size you can use height, width CSS properties for the box and the image.

Nested divs should resize according to the divs inside them, but they dont

I do not understand why the rightcontent and leftcontent divs do not stay in the centerbody div when the number of "< p>"s is increased.
I have attached a picture of what happens.
The dots should stay inside the white space. And the white space should auto resize according to the length of the content. Shouldnt it?
<html>
<style media="screen" type="text/css">
body {
background-color: #efefef;
}
h1 {
color: white;
text-align: center;
font-family: "Trebuchet MS", Helvetica, sans-serif;
}
p {
font-family: verdana;
font-size: 20px;
}
#centerbody { /*this is the style of the main body white box */
background-color: white;
box-shadow: 0 4px 8px 0 rgba(0, 0, 0, 0.2), 0 6px 20px 0 rgba(0, 0, 0, 0.19);
border-radius: 5px 5px 5px 5px;
padding: 20px;
margin: 100px 50px 100px 50px;
font-family: "Trebuchet MS", Helvetica, sans-serif;
font-size: 20px;
}
#rightContent {
float:right;
width: 50%;
margin-bottom: 20px;
}
#leftContent {
float:left;
width: 50%;
margin-bottom: 20px;
}
</style>
<body>
<div id="centerbody">
<div id="rightContent">
<p>.</p>
<p>.</p>
<p>.</p>
<p>.</p>
<p>.</p>
<p>.</p>
</div>
<div id="leftContent">
right side stuff
</div>
</div>
</body>
</html>
You can do a few things:
Float #centerbody left or right.
Set #centerbody to display:inline-block
Use the "clear" trick, by having an empty DIV after your floating DIVs that has "clear:both"
To explain: a floating element's height is not added to its container. Floating elements DO listen to the height of other floating elements. So by setting your parent container to float, or inline-block, you're letting it take into account its child elements' heights.
The clear trick is an old move if the other two options aren't viable for the rest of your project, as it injects a normal block element into the container, working as a signal for the container on where the "end " of the container should be.
Your content is coming out of the div's that are being floated.
You probably don't know what the float has an impact on it's parent.
You should definitely read the following article All About Floats
Note: It's one of the most important concepts in CSS(another one is positioning) so I recommend you to read the mentioned article.
If you want a quick answer then do this:
{parent-div}:before, {parent-div}:after{
clear: both;
content: "";
display: block; //or inline-block
}
What clear and content do is explained well in the mentioned article.
As an alternative, you can set your parent container as a flex box and give your parent an explicit width
body {
background-color: #efefef;
}
h1 {
color: white;
text-align: center;
font-family: "Trebuchet MS", Helvetica, sans-serif;
}
p {
font-family: verdana;
font-size: 20px;
}
#centerbody { /*this is the style of the main body white box */
background-color: white;
box-shadow: 0 4px 8px 0 rgba(0, 0, 0, 0.2), 0 6px 20px 0 rgba(0, 0, 0, 0.19);
border-radius: 5px 5px 5px 5px;
padding: 20px;
width: 500px;
display: flex;
flex-direction: row;
justify-content: space-between;
margin: 100px 50px 100px 50px;
font-family: "Trebuchet MS", Helvetica, sans-serif;
font-size: 20px;
}
#rightContent {
width: 50%;
margin-bottom: 20px;
}
#leftContent {
width: 50%;
margin-bottom: 20px;
}
.clearfix:after {
content: "";
display: table;
clear: both;
}
<body>
<div id="centerbody">
<div id="leftContent">
<p>
hello
</p>
</div>
<div id="rightContent">
right side stuff
<p>.</p>
<p>.</p>
<p>.</p>
<p>.</p>
<p>.</p>
<p>.</p>
</div>
</div>
</body>
Please Check the Edit history to get a clear idea
maybe this is what you are looking for
body {
background-color: #efefef;
}
h1 {
color: white;
text-align: center;
font-family: "Trebuchet MS", Helvetica, sans-serif;
}
p {
font-family: verdana;
font-size: 20px;
}
#centerbody { /*this is the style of the main body white box */
background-color: white;
box-shadow: 0 4px 8px 0 rgba(0, 0, 0, 0.2), 0 6px 20px 0 rgba(0, 0, 0, 0.19);
border-radius: 5px 5px 5px 5px;
padding: 20px;
margin: 100px 50px 100px 50px;
font-family: "Trebuchet MS", Helvetica, sans-serif;
font-size: 20px;
}
#rightContent {
float:right;
text-align: center;
width: 50%;
margin-bottom: 20px;
}
#leftContent {
line-height: 300px;
vertical-align: middle;
float:left;
width: 50%;
margin-bottom: 20px;
}
#empty{
clear:both;
}
<div id="centerbody">
<div id="leftContent">
right side stuff
</div>
<div id="rightContent">
<p>.</p>
<p>.</p>
<p>.</p>
<p>.</p>
<p>.</p>
<p>.</p>
</div>
<div id="empty"></div>
</div>

Gap Between Two Div's in One page web site

I am Trying to create this One page containing different divs with 100% width.
But, when I insert a 'h2' at top of div, itcreates gap between two div's.
assigning top margin removes this gap, but I want the 'h2' at top only.
here's JSFiddle
HTML:
html,
body {
height: 100% !important;
width: 100% !important;
margin: 0px;
padding: 0px;
}
.mainDiv {
height: 500% !important;
width: 100% !important;
}
.page {
height: 20% !important;
width: 100% !important;
text-align: center;
}
#headerDiv {
height: 15%;
position: fixed;
background-color: #7f4c76;
width: 100%;
box-shadow: 0px 5px 5px rgba(0, 0, 0, 0.4);
}
#div1 {
padding-top: 5%;
background-color: #334960;
}
#div2 {
background-color: #f17c72;
}
#div3 {
background-color: #32ac97;
}
#div4 {
background-color: black;
}
#div5 {
background-color: yellow;
}
h1 {
color: #E6E6E6;
margin-left: 50px;
font-family: "MS Sans Serif", Geneva, sans-serif;
font-size: 300%;
text-shadow: 0px 5px 5px rgba(0, 0, 0, 0.4);
}
h2 {
color: #E6E6E6;
font-weight: normal;
font-family: 'Signika', sans-serif;
font-size: 300%;
}
<div class="mainDiv">
<div id="headerDiv">
<h1>CSS3 Demo </h1>
</div>
<div id="div1" class="page">
<h2>Text Effects Demo</h2>
</div>
<div id="div2" class="page">
<h2>Transition Demo</h2>
</div>
<div id="div3" class="page">
<h2>Animation Demo</h2>
</div>
<div id="div4" class="page">
<h2>Multiple Columns</h2>
</div>
<div id="div5" class="page">
<h2>Multiple Columns</h2>
</div>
</div>
Please Help.
Edit screenshot added:
Add this to your h2
h2 {
margin:0;
}
You issue is that your div has a default margin, of which can be overwritten using this styling
If I understood you correctly, you want the <h1>from the headerDivto have margin-top:0px; if this is what you want then the fix is quite simple:
#headerDiv h1 {
margin-top:0px;
}
Or if you want it to be only the direct descendants from the headerDiv you could do the following:
#headerDiv > h1 {
margin-top:0px;
}
Here you can find the fiddle updated: http://jsfiddle.net/s0p8ogdb/3/
After seeing the screenshot recently added you can fix this simply by making the page class display:inline-block, here's an updated fiddle: http://jsfiddle.net/s0p8ogdb/4/
Try this :
h2 {
color: #E6E6E6;
font-weight: normal;
font-family: 'Signika', sans-serif;
font-size: 300%;
margin-top:0;
}
#div1 h2 {
padding-top: 1em
}

Center text horisontaly and verticaly in an image

I want to change the text on the photos to be in the center, both horisontal and vertical. It's currently centered horisontally, but not vertically. Remember it's a "hover-effect background image"-thing.
HTML
<a href="portrait">
<div id="imagebox1" class="imagebox columns">
<div id="image1">
<span id="plus">Portrett</span>
</div>
</div>
</a>
<a href="nature">
<div id="imagebox3" class="imagebox columns">
<div id="image3">
<span id="plus">Natur</span>
</div>
</div>
</a>
<a href="various">
<div id="imagebox2" class="imagebox columns">
<div id="image2">
<span id="plus">Annet</span>
</div>
</div>
</a>
CSS
#imagebox1, #imagebox2, #imagebox3 {
float: left;
background-repeat: no-repeat;
margin-right: 0px;
}
#imagebox1 {
background:url(../images/sample_image400.jpg);
background-size: cover;
margin-left: 0px;
}
#imagebox2 {
background:url(../images/sample_image.jpg);
background-size: cover;
}
#imagebox3 {
background:url(../images/sample_image.jpg);
background-size: cover;
}
#image1, #image2, #image3 {
background:rgba(255,255,255,.75);
text-align:center;
padding-top: 100%;
opacity:0;
-webkit-transition: all 0.3s ease-in-out;
}
#imagebox1:hover #image1 {
opacity:1;
}
#imagebox2:hover #image2 {
opacity:1;
}
#imagebox3:hover #image3 {
opacity:1;
}
.images img {
margin-left: 0px;
padding-bottom:30px;
padding-top:35px;
}
#imagebox1, #imagebox2, #imagebox3 {
margin-bottom: 30px;
}
#plus {
font-family: Gotham, "Helvetica Neue", Helvetica, Arial, sans-serif;
font-weight: 200;
color: #282828;
font-size: 20px;
text-transform: uppercase;
}
JSFIDDLE
http://jsfiddle.net/8abCY/
Ok...I think your HTML structure is too complex for what you are trying to do.
So I've simplified it.
JSfiddle DEmo
The image is content and so it should be in the HTML not a background-image in the CSS which gives us, simply
HTML
<a href="portrait" class="imagebox">
<img src="http://www.ginakorslund.no/images/sample_image400.jpg" alt=""/>
<span class="plus">Portrett</span>
</a>
Note I'be changed a lot of the ID out for a more generic class. you can still give each anchor link an individual ID if you want but the classes mean that the CSS is re-usable.
CSS
.imagebox {
position: relative; /* required */
text-align: center;
display: block;
}
.plus {
position: absolute;
top:50%; /* top and left values put the span's top left corner exactly */
left:50%; /* halfway down and across the screen but do **not** center it */
-webkit-transform:translate(-50%, -50%);
transform:translate(-50%, -50%);
/* move the span back exactly half it's own width and height */
/* and now it's centered regardless of width & height */
display: none; /* hide it until hovered */
font-family: Gotham, "Helvetica Neue", Helvetica, Arial, sans-serif;
font-weight: 200;
color: #282828;
font-size: 20px;
text-transform: uppercase;
color:white;
}
.imagebox:hover .plus {
display: block; /* show it when the link is hovered */
}
try...
#plus {
font-family: Gotham, "Helvetica Neue", Helvetica, Arial, sans-serif;
font-weight: 200;
color: #282828;
font-size: 20px;
text-transform: uppercase;
position: relative;
margin-top: auto;
margin-bottom: auto;
}