Text-align property does not work inside button - html

I am developing interactive map. I have svg vector map itself and different buttons(divs with link inside), styled as circles. Vector, buttons and pop-ups are nested in div "map". The click on button link opens the pop-up with text. The problem is: I cannot center-align the link text on a button.Text is centered, but sticks at the top of the button. I have tried to nest link inside button with same styling as my "div variant" has now - that is the only way i get normal centered link texts. But such way is invalid - doesnt work for IE and moz
.button-my{width:25px;
height:25px;
border-radius: 50%;
text-decoration:none;
background: #FFC651 !important ;
text-align: center;
color: #FFC651 !important;
font-family: 'Roboto', sans-serif !important;;
font-size: 20%;
top: 34%;
left: 49%;
position: absolute;
margin: 0 !important;
padding: 0 !important;
border: none !important;
-webkit-animation: rainbow 2s infinite;}
#-webkit-keyframes rainbow {
0% {opacity: 1}
50% {opacity: 0.5}
100% {opacity: 1}
}
.button-my:hover {
transform: scale(4);
transition: all .5s ease-in-out;
z-index: 5;
-webkit-animation: none;
}
.my{
display: inline-block;
top: 33%;
left: 45%;
background-color: #00C3D1;
opacity: 0.5;
position: absolute;
padding: 0,5%;
visibility: hidden;
opacity: 0;
width:10%;
border-radius: 5%;
transition: opacity 800ms;
z-index: 5;
}
.my:target {
visibility: visible;
opacity: 0.9;
}
a{
text-decoration: none;
color: white !important;
padding: 0 !important;
text-align: center !important;
margin: auto;
}
a:hover{
text-decoration: underline;
}
div{
z-index: 5;
}
.map{
position: relative;
margin-left: auto;
margin-right: auto;
}
<div class="map"><img src="../img/graph.svg">
<div class="button-my">Text</button>
<div class="my" id="my"><a href="
http://www.my.com" target="_blank"><h1>Random pop-up text</h1>
</a>
<a class="close" href="#">×</a>
</div></div>

You need to either increase the line-height to 25px so it fills the height of the button, or increase the top padding to push the text down into position.
You should almost always avoid using height in CSS. In this case, it's better to change the height of the contents to achieve the height you want... then the height of the button will be determined from that (line-height + top padding + bottom padding).

.button-my {
width: 25px;
height: 25px;
line-height: 25px;
...
}

add line height to a
.button-my a{
line-height: 25px;
}
.button-my{width:25px;
height:25px;
border-radius: 50%;
text-decoration:none;
background: #FFC651 !important ;
text-align: center;
color: #FFC651 !important;
font-family: 'Roboto', sans-serif !important;;
font-size: 20%;
top: 34%;
left: 49%;
position: absolute;
margin: 0 !important;
padding: 0 !important;
border: none !important;
-webkit-animation: rainbow 2s infinite;}
#-webkit-keyframes rainbow {
0% {opacity: 1}
50% {opacity: 0.5}
100% {opacity: 1}
}
.button-my:hover {
transform: scale(4);
transition: all .5s ease-in-out;
z-index: 5;
-webkit-animation: none;
}
.button-my a{
line-height: 25px;
}
.my{
display: inline-block;
top: 33%;
left: 45%;
background-color: #00C3D1;
opacity: 0.5;
position: absolute;
padding: 0,5%;
visibility: hidden;
opacity: 0;
width:10%;
border-radius: 5%;
transition: opacity 800ms;
z-index: 5;
}
.my:target {
visibility: visible;
opacity: 0.9;
}
a{
text-decoration: none;
color: white !important;
padding: 0 !important;
text-align: center !important;
margin: auto;
}
a:hover{
text-decoration: underline;
}
div{
z-index: 5;
}
.map{
position: relative;
margin-left: auto;
margin-right: auto;
}
<div class="map"><img src="../img/graph.svg">
<div class="button-my">Text</button>
<div class="my" id="my"><a href="
http://www.my.com" target="_blank"><h1>Random pop-up text</h1>
</a>
<a class="close" href="#">×</a>
</div></div>

Related

Continuous Scrolling Effect in CSS stopping on first line

I'm trying to create a continuous vertical scroller effect, however having a couple of issues;
The first line appears, without stopping, like the rest of the
line
I can't seem to fade-in or fade-out
For the first point, I've tried adjusting the keyframe at 0%, too many different options and div heights, but haven't got anywhere.
On the second point, i've tried adding from: {opacity: 0.5} and to: {opacity: 0.5}, again to no success.
How do I stop the scrolling effect at the first line, like what happens with the subsequent line and add a fade-in fade-out effect?
JSFiddle: https://jsfiddle.net/ekzvLhmx/
CSS
.tagTextContainer {
text-align: left;
display: inline-flex;
width: 100%;
margin: 5px;
border-bottom: 1px solid #dcdfe5;
}
.tagText {
text-align: left;
color: black;
font-size: 13px;
}
.scrollCont {
font: normal 40px/50px monospace;
float: left;
overflow: hidden;
position: relative;
height: 18px;
top: 0px;
}
.scrollCont .scrollOptions {
font-size: 13px;
display: inline-block;
color: black;
position: relative;
top: 0;
left: 0;
/*animation*/
animation: scroll 10s;
/*animation-iteration-count*/
animation-iteration-count: infinite;
/*animation-delay*/
animation-delay: 1.5s;
}
#keyframes scroll {
0% {
top: 0px;
}
20% {
top: -66px;
}
40% {
top: -116px;
}
60% {
top: -166px;
}
80% {
top: -216px;
}
}
HTML
<div class="tagTextContainer">
<span class="tagText">
Options:
</span>
<div class="scrollCont">
<div class="scrollOptions">
SJDIUNE92323232<br />
FHD_231232_FSD<br />
RUG_12£321231$3<br />
LA21312321_TQ<br />
2132131/232 123
</div>
</div>
</div>
The problem is the first item is a little below what you expect.
I modified your version a little here
<div class="tagTextContainer">
<span class="tagText">
Options:
</span>
<div class="scrollCont">
<div class="scrollOptions">
SJDIUNE92323232<br />
FHD_231232_FSD<br />
RUG_12£321231$3<br />
LA21312321_TQ<br />
2132131/232 123
</div>
</div>
</div>
.tagTextContainer {
text-align: left;
display: inline-flex;
width: 100%;
margin: 5px;
border-bottom: 1px solid #dcdfe5;
}
.tagText {
text-align: left;
color: black;
font-size: 13px;
}
.scrollCont {
font: normal 40px/50px monospace;
float: left;
overflow: hidden;
position: relative;
height: 18px;
top: 0px;
}
.scrollCont .scrollOptions {
font-size: 13px;
display: inline-block;
color: black;
position: relative;
top: 0;
left: 0;
/*animation*/
animation: scroll 10s;
/*animation-iteration-count*/
animation-iteration-count: infinite;
/*animation-delay*/
animation-delay: 1.5s;
}
#keyframes scroll {
16% {
top: -15px;
}
32% {
top: -66px;
}
48% {
top: -116px;
}
64% {
top: -166px;
}
80% {
top: -216px;
}
}

CSS Opacity on Rollover Image with Text, but No Opacity Change on Text

I have an image, with text on top. When I rollover the Image I want the opacity of the background image to lower, but not the opacity for the text above it.
I thought that since the text was in a span i could simply tell the span to have the opacity: 1 !important; however that doesn't seem to do the trick. Can anyone help?
Here is the JSFiddle: https://jsfiddle.net/zerojjc/xrwao8n9/
HTML:
<div class="boxThird">
<a class="btnBox boxOne" href="<?php bloginfo('url'); ?>/" title="About Heath, Fania & Co"><span>About</span></a>
</div>
CSS:
.boxThird {
float: left;
width: 33.33%;
height: 400px;
background: #000;
}
.boxThird span {
margin-left: 25px;
position: relative;
top: 344px;
text-decoration: none;
border-bottom: 1px solid #fff;
}
.btnBox {
display: block;
text-align: left;
color: #fff;
text-shadow: 0px 0px 2px #555;
text-transform: uppercase;
text-decoration: none;
font-weight: 400;
font-size: 2em;
letter-spacing: .125em;
}
.boxOne {
height: 100%;
width: 100%;
background-position: center;
background-size: cover;
}
.boxOne {
background-image: url(https://i.imgur.com/izS0fLZ.jpg);
}
.boxOne:hover{
opacity: 0.8;
}
.boxOne:hover span{
opacity: 1 !important;
}
Opacity cascades, which means that if you have a span inside a div and they both have 0.8 opacity, the child-span would actually have 80% opacity of the parents 80% opacity (so IDK, 64% opacity). So by setting opacity: 1 to your span, you basically set it to the parents 0.8 opacity.
To prevent this, you can move the background image into a :before pseudo element and just change the :before opacity.
You can see a working example here:
https://jsfiddle.net/xr06hby2/
Relevant CSS:
.boxOne {
position: relative;
}
.boxOne:before {
content: '';
background-image: url(https://i.imgur.com/izS0fLZ.jpg);
background-position: center;
background-size: cover;
position: absolute;
top: 0;
right: 0;
bottom: 0;
left: 0;
opacity: 1;
transition: opacity 0.3s;
}
.boxOne:hover:before{
opacity: 0.3;
}

CSS positioning helper tips icon

Good Morning,
I have this line of code:
<div class="navigation">
<a href="~/Uploads/TimeSlotTemplate.xlsx" download>Download Upload Template</a> <div class="help-tip"> <p>This is the inline help tip! You can explain to your users what this section of your web app is about.</p></div>
<a href="~/Uploads/TimeSlotTemplate.xlsx" download>Download Upload Template</a> <div class="help-tip"> <p>This is the inline help tip! You can explain to your users what this section of your web app is about.</p></div></div>
What I am trying to do is have the help-tip div go right next to the link. The paragraph appears when you put your mouse over the help-tip div. I am looking to get the paragraph to go directly under the help-tip icon in short of an overlay style. When I remove the position absolute for the both elements the icon goes right next to the icon and the paragraph goes under the icon, but it creates a massive amount of space.
Here is my css
.help-tip{
position: absolute;
top: 18px;
right: 18px;
text-align: center;
background-color: #BCDBEA;
border-radius: 50%;
width: 24px;
height: 24px;
font-size: 14px;
line-height: 26px;
cursor: default;
}
.help-tip:before{
content:'?';
font-weight: bold;
color:#fff;
}
.help-tip:hover p{
display:block;
transform-origin: 100% 0%;
-webkit-animation: fadeIn 0.3s ease-in-out;
animation: fadeIn 0.3s ease-in-out;
}
.help-tip p{ /* The tooltip */
display: none;
text-align: left;
background-color: #1E2021;
padding: 20px;
width: 300px;
position: absolute;
border-radius: 3px;
box-shadow: 1px 1px 1px rgba(0, 0, 0, 0.2);
right: -4px;
color: #FFF;
font-size: 13px;
line-height: 1.4;
}
.help-tip p:before{ /* The pointer of the tooltip */
position: absolute;
content: '';
width:0;
height: 0;
border:6px solid transparent;
border-bottom-color:#1E2021;
right:10px;
top:-12px;
}
.help-tip p:after{ /* Prevents the tooltip from being hidden */
width:100%;
height:40px;
content:'';
position: absolute;
top:-40px;
left:0;
}
/* CSS animation */
#-webkit-keyframes fadeIn {
0% {
opacity:0;
transform: scale(0.6);
}
100% {
opacity:100%;
transform: scale(1);
}
}
#keyframes fadeIn {
0% { opacity:0; }
100% { opacity:100%; }
}
and here is a jfiddle
https://jsfiddle.net/13275tvz/1/
Need some HTML and CSS Fix
When you are making the element position absolute, make sure it's parent have the position relative property.
HTML
<div class="navigation">
<div class="link-container">
<a href="~/Uploads/TimeSlotTemplate.xlsx" download>Download Upload Template</a> <div class="help-tip"> <p>This is the inline help tip! You can explain to your users what this section of your web app is about.</p></div>
</div>
<div class="link-container">
<a href="~/Uploads/TimeSlotTemplate.xlsx" download>Download Upload Template</a> <div class="help-tip"> <p>This is the inline help tip! You can explain to your users what this section of your web app is about.</p></div></div>
</div>
CSS
.help-tip{
position: absolute;
top: 18px;
right: 18px;
text-align: center;
background-color: #BCDBEA;
border-radius: 50%;
width: 24px;
height: 24px;
font-size: 14px;
line-height: 26px;
cursor: default;
}
.link-container{
position:relative;
display:inline-block;
}
.help-tip:before{
content:'?';
font-weight: bold;
color:#fff;
}
.help-tip:hover p{
display:block;
transform-origin: 100% 0%;
-webkit-animation: fadeIn 0.3s ease-in-out;
animation: fadeIn 0.3s ease-in-out;
}
.help-tip p{ /* The tooltip */
display: none;
text-align: left;
background-color: #1E2021;
padding: 20px;
width: 300px;
position: absolute;
border-radius: 3px;
box-shadow: 1px 1px 1px rgba(0, 0, 0, 0.2);
right: -4px;
color: #FFF;
font-size: 13px;
line-height: 1.4;
}
.help-tip p:before{ /* The pointer of the tooltip */
position: absolute;
content: '';
width:0;
height: 0;
border:6px solid transparent;
border-bottom-color:#1E2021;
right:10px;
top:-12px;
}
.help-tip p:after{ /* Prevents the tooltip from being hidden */
width:100%;
height:40px;
content:'';
position: absolute;
top:-40px;
left:0;
}
/* CSS animation */
#-webkit-keyframes fadeIn {
0% {
opacity:0;
transform: scale(0.6);
}
100% {
opacity:100%;
transform: scale(1);
}
}
#keyframes fadeIn {
0% { opacity:0; }
100% { opacity:100%; }
}
Style Accordingly..
Link for reference
hope this helps..
you need change position to relative, display to inline-block and desmiss top, right.
.help-tip {
position: relative;
/* top: 18px; */
/* right: 18px; */
text-align: center;
background-color: #BCDBEA;
border-radius: 50%;
width: 24px;
height: 24px;
font-size: 14px;
line-height: 26px;
cursor: default;
display: inline-block;
}

How to transform box-shadow from left to right

How can I make it so that the box-shadow transforms from left to right without adding the transform effect to the text itself.
This text will change sizes depending on the content so the box-shadow needs to be adjusted accordingly.
Currently my code looks like this.
body {
background-color: #FFFFFF;
margin: 0px;
-webkit-font-smoothing: antialiased;
-moz-osx-font-smoothing: grayscale;
}
.container {
display: block;
width: 85%;
/*center vertically & horizontally*/
position:absolute; top:50%; left:50%;
-webkit-transform:translate(-50%,-50%);
-moz-transform:translate(-50%,-50%);
-ms-transform:translate(-50%,-50%);
transform:translate(-50%,-50%);
}
a, a:visited, a:hover {
/*display: block; this makes the whole line justified*/
-ms-text-align-last: justify;
-moz-text-align-last: justify;
text-align-last: justify;
text-decoration: none;
color: #000000;
/*box-shadow: inset 0 -1.3vw 0 0 #00f9ff; OLD SCRIPT*/
}
#test1 {
display: inline-block;
height: auto;
width: auto;
visibility: visible;
box-shadow: inset 0 -1.3vw 0 0 #00f9ff;
font-family: "Times New Roman", Times, serif;
text-align: center;
line-height: 7.5vw;
margin: 0;
font-size: 7.7vw;
font-weight: bold;
animation: stretchRight;
-webkit-animation: stretchRight;
animation-duration: 1s;
-webkit-animation-duration: 1s;
animation-timing-function: ease-out;
-webkit-animation-timing-function: ease-out;
transform-origin: 0% 0%;
-ms-transform-origin: 0% 0%;
-webkit-transform-origin: 0% 0%;
}
#keyframes stretchRight {
0% {
transform: scaleX(0);
}
100% {
transform: scaleX(1);
}
}
<html>
<head>
<link rel="stylesheet" href="style.css">
</head>
<body>
<div class="container">
<div id="test1">hello darkness my old</div>
</div>
</div>
</body>
</html>
What you want to do is use a pseudo element that you can animate.
I've added the animation to the hover state for better testing
body {
background-color: #FFFFFF;
margin: 0px;
-webkit-font-smoothing: antialiased;
-moz-osx-font-smoothing: grayscale;
}
.container {
display: block;
width: 85%;
/*center vertically & horizontally*/
position:absolute; top:50%; left:50%;
-webkit-transform:translate(-50%,-50%);
-moz-transform:translate(-50%,-50%);
-ms-transform:translate(-50%,-50%);
transform:translate(-50%,-50%);
}
a, a:visited, a:hover {
position: relative;
/*display: block; this makes the whole line justified*/
-ms-text-align-last: justify;
-moz-text-align-last: justify;
text-align-last: justify;
text-decoration: none;
color: #000000;
}
#test1 {
display: inline-block;
height: auto;
width: auto;
visibility: visible;
font-family: "Times New Roman", Times, serif;
text-align: center;
line-height: 7.5vw;
margin: 0;
font-size: 7.7vw;
font-weight: bold;
}
#test1 a:after {
position: absolute;
bottom: 0;
left: 0;
width: 0;
height: 3px;
content: "";
background: #00f9ff;
transition: width .2s ease-in-out;
}
#test1 a:hover:after {
width: 100%;
}
<html>
<head>
<link rel="stylesheet" href="style.css">
</head>
<body>
<div class="container">
<div id="test1">hello darkness my old</div>
</div>
</div>
</body>
</html>
If you want to use animation and also the same box-shadow . Make a pseudo element with the same width,height,box-shadow as the #test1 div. Also scale it to 0 at first, and then apply the animation to it.
Using animation instead of transition will let you activate the animation on page load, not on an event like hover focus etc. Which is what i think you want
see snippet below
#test1 {
display: inline-block;
height: auto;
width: auto;
visibility: visible;
font-family: "Times New Roman", Times, serif;
text-align: center;
line-height: 7.5vw;
margin: 0;
font-size: 7.7vw;
font-weight: bold;
position: relative;
}
#test1:before {
content: "";
box-shadow: inset 0 -1.3vw 0 0 #00f9ff;
position: absolute;
width: 100%;
height: 100%;
left: 0;
top: 0;
transform: scaleX(0);
transform-origin: left;
animation-name: stretchRight;
animation-delay: 0.5s;
animation-duration: 0.8s;
animation-fill-mode: forwards;
animation-timing-function: ease-out;
z-index:-1;
}
a {
text-decoration: none;
}
#keyframes stretchRight {
0% {
transform: scaleX(0);
}
100% {
transform: scaleX(1);
}
}
<div class="container">
<div id="test1">
hello darkness my old
</div>
</div>

How to write Text on a image.

How to add TEXT in the image...so that the TEXT is view-able only when the image becomes dark when mouse is placed over it.. something like ..the one given in the example image below...
Thanks for your help.
.image {
width: 250px;
height: 200px;
background: black;
position: relative;
overflow: hidden;
}
.image img {
transition: all ease 1s;
}
.image:hover img { /* Darkening effect on mouseover */
background: black;
opacity: 0.7;
}
.image .arrow { /* Creates a half triangle with top and left arrow transparent */
opacity: 0;
border-color: transparent #f2f2f2 #f2f2f2 transparent;
transition: all ease 1s;
position: relative;
}
.image:hover .arrow { /* Mouseover effect */
opacity: 1;
font-family: Roboto;
font-size: 36px;
text-align: center;
border-image: none;
border-style: solid;
border-width: 45px;
position: absolute;
bottom: 0;
font-weight: normal;
width: 0;
height: 0;
right: 0;
}
.image:hover .arrow {
border-image: none;
border-style: solid;
border-width: 45px;
bottom: 0;
display: block;
font-family: Roboto;
font-size: 36px;
font-weight: normal;
height: 0;
opacity: 1;
position: absolute;
right: 0;
text-align: center;
width: 0;
}
.image .arrow {
border-color: transparent #f2f2f2 #f2f2f2 transparent;
opacity: 0;
position: relative;
transition: all 1s ease 0s;
}
.image .arrow span {
left: 5px;
position: relative;
top: -10px;
}
<div class="image">
<img src="http://lorempixel.com/250/200/sports" />
<div class="arrow"><span>></span></div>
</div>
enter image description here
It's simple. Create some text inside your wrapper div, then order the text to display on hovering the wrapper. Below is a demo of this logic.
The HTML:
<div class="image">
<p>I'm some very interesting text!</p>
<div class="arrow"><span>></span></div>
</div>
The CSS:
p{
color: #fff;
opacity: 0;
font-weight: bold;
text-align: center;
font-size:32px;
color: red;
/* bring your own prefixes */
transform: translate(0, 50%);
transition: all .5 ease;
}
.image:hover p {
visibility: visible;
opacity: 1;
}
CODEPEN DEMO
i think you can create like this
you need to change the position of the .image class so that text div can appear overlap on that
.image-hover-wrapper {
display:none;
text-align: center;
width: 250px;
color: red;
font-size: 35px;
position: relative;
top: -125px;
background: rgba(255,255,255,0.6);
}
.image:hover > .image-hover-wrapper{
display:block;
opacity:0.8;
transition-property: animation;
transition-duration: 2s;
transition-timing-function: linear;
}
<div class="image">
<img src="http://lorempixel.com/250/200/sports" />
<div class="arrow"><span></span></div>
<div class="image-hover-wrapper">
Hii
</div>
</div>
and here is the
Updated DEmo