Button Jumping On Click - html

I've made a landing page for my BTEC Media coursework, but I've ran into an issue with a button.
When I click on my call to action button the button grows in length. I've tried setting max-width to auto and altering margins but the same result.
Here is my CSS and HTML
HTML Code
<!-- Contact Button Bottom Right-->
<a href="mailto:fake#email.com?subject=Envirma Education | Media Production Unit 6&body=To the attention of sir/madam,
Envirma Education | Media Production Unit 6" class="call-to-action">Click here to contact us! <i class="far fa-envelope-open"></i>
</a>
<!-- End of Contact Call-To-Action-->
CSS Code
/* Call to Action */
.call-to-action {
background-color:#ffffff;
border:1px solid #ffffff;
-moz-border-radius:28px;
-webkit-border-radius:28px;
border-radius:28px;
display:inline-block;
font-size:17px;
font-family: 'Roboto, Sans Serif';
text-decoration:none;
color:#000000;
padding:16px 31px;
position: absolute;
display: block;
right: 50px;
bottom: 60px;
text-align: center;
}
​ .call-to-action a:hover {
background-color:#C6DDF0;
border:1px solid #C6DDF0;
}
.call-to-action a{
text-decoration: none;
color: #ffffff
}
.call-to-action:hover {
background-color:#C6DDF0;
}
.call-to-action:active {
position:relative;
top:1px;
}
Thanks for reading and any help provides.
This may be a really easy solve but I'm fairly new to programming and couldn't find any results online relating to my exact problem.
Photo of button expanding width on click.

Your active anchor class was sending your button to the top 1px. Just remove that and it no longer jumps. Perhaps you meant to drop the button by 1px when clicked. If so, try increasing the margin-top by 1px:
.call-to-action {
background-color: #ffffff;
border: 1px solid #ffffff;
-moz-border-radius: 28px;
-webkit-border-radius: 28px;
border-radius: 28px;
display: inline-block;
font-size: 17px;
font-family: 'Roboto, Sans Serif';
text-decoration: none;
color: #000000;
padding: 16px 31px;
position: absolute;
display: block;
right: 50px;
bottom: 60px;
text-align: center;
}
​ .call-to-action a:hover {
background-color: #C6DDF0;
border: 1px solid #C6DDF0;
}
.call-to-action a {
text-decoration: none;
color: #ffffff
}
.call-to-action:hover {
background-color: #C6DDF0;
}
.call-to-action:active {
position: relative;
}
<a href="mailto:fake#email.com?subject=Envirma Education | Media Production Unit 6&body=To the attention of sir/madam,
Envirma Education | Media Production Unit 6" class="call-to-action">Click here to contact us! <i class="far fa-envelope-open"></i>
</a>

Just remove the positioning on the active anchor class.
.call-to-action:active {
position:relative;
}

Removed the following anchor and took out the top tag as it was moving it on click/active.
.call-to-action:active {
position: relative;
}
Thanks to MichaelvE for the response.

Related

How to create the expected button in HTML?

The first image was captured in Python online course. The second image was captured in my own website. I want to mimic this website for practicing html/css skill. What I want to know is how to create the expected button. Thank you for your reply.
/*Here is my CSS code, which is unfinished.*/
.Matter a:hover{
background-color: rgb(230,230,230);
}
<!-- Here is my HTML code -->
<div class='Matter'>
<h1>Welcome to the Capstone</h1>
<p><a href='#'><b>Video:</b> Introduction: Welcome to the Class</a></p>
<p><a href='#'><b>Reading:</b> Capstone Overview</a></p>
<p><a href='#'><b>Reading:</b> Help Us Learn More About You!</a></p>
</div>
Let's handle your problem step by step:
Styling the link: We are going to add some padding, text decoration and color. We are also using display inline-block for our link take full width.
.Matter a {
padding: 8px;
display: inline-block;
width: 100%;
text-decoration: none;
color: black;
}
Adding hover style:
.Matter a:hover{
background-color: rgb(230,230,230);
}
Adding checkmark: We need to use CSS Pseudo element ::before to add the check mark in front of the link. To add the green circle around the check mark we are using some margin, padding, border radius, background, color and font size. We are also using position to adjust the check mark circle position.
.Matter a::before {
content: '🗸';
margin-right: 8px;
padding: 2px 4px;
background: green;
border-radius: 50%;
color: white;
font-size: 12px;
position: relative;
top: -2px;
}
Here's the complete solution. You can play with it as you wish.
.Matter a {
padding: 8px;
display: inline-block;
width: 100%;
text-decoration: none;
color: black;
}
.Matter a:hover{
background-color: rgb(230,230,230);
}
.Matter a::before {
content: '🗸';
margin-right: 8px;
padding: 2px 4px;
background: green;
border-radius: 50%;
color: white;
font-size: 12px;
position: relative;
top: -2px;
}
<div class='Matter'>
<h1>Welcome to the Capstone</h1>
<p><a href='#'><b>Video:</b> Introduction: Welcome to the Class</a></p>
<p><a href='#'><b>Reading:</b> Capstone Overview</a></p>
<p><a href='#'><b>Reading:</b> Help Us Learn More About You!</a></p>
</div>

Call to Action Button Stuck in Middle of Page

My 'Click here to contact us!' button is sticking to the middle of the page instead of floating at the bottom, here is the code and an image attached. I recently faced an issue where the button was changing size on being clicked which was rectified, however now my problem is it floating in the middle of the page.
Is this a problem with a margin or height set?
* Call to Action */
.call-to-action {
background-color: #ffffff;
border: 1px solid #ffffff;
-moz-border-radius: 28px;
-webkit-border-radius: 28px;
border-radius: 28px;
display: block;
font-size: 17px;
font-family: 'Roboto, Sans Serif';
text-decoration: none;
color: #000000;
padding: 16px 31px;
position: absolute;
right: 50px;
bottom: 30px;
text-align: center;
transition: 0.5s;
margin: auto;
}
.call-to-action a:hover {
background-color: #C6DDF0;
border: 1px solid #C6DDF0;
}
.call-to-action a {
text-decoration: none;
color: #ffffff
}
.call-to-action:hover {
background-color: #C6DDF0;
}
<!--Button Bottom Right-->
<a href="mailto:example#example.com?subject=Envirma Education | Media Production Unit 6&body=To the attention of sir/madam,
Envirma Education | Media Production Unit 6" class="call-to-action">Click here to contact us! <i class="far fa-envelope-open"></i>
</a>
<!--End of Contact Call-To-Action-->

How to create link in content element

I have been tasked with creating this.
I can create the box, font-awesome icon and the non-linking text using a pseudo element content, but I am unable to create the Learn More link (with a span class to include the >).
If I add text directly into the html, it will not fill the box (and spills out below it). I would also be forced to use inline styles to keep it top-aligned with the !.
We want to keep this in the CSS if at all possible. I realize that the real answer is that you can't do it, but I'm looking for a workaround to make it work.
This is the CSS I can use to place the non-linking message:
&:after {
color: #7b7b7b;
margin-top: -43px;
padding-left: 19%;
line-height: 18px;
display: flex;
font-weight: normal;
content: "You are no longer on FPC, you will now be back to your regular contract.";
#media #{$small} {
padding-left: 15%;
margin-top:-37px;
}
}
&:before {
color: #7b7b7b;
margin-left: 10px;
}
And this is the line of HTML:
<i class="fa fa-exclamation-circle"></i>; Learn more <span class="arrow-right"></span>
Does anyone have a solution to help me make this work?
Thanks
Here is a different structure & CSS if you end up going in that direction.
.message {
border: 2px solid #7b7b7b;
border-radius: 2px;
position: relative;
width: 220px;
font-size: 13px;
font-family: Arial;
background: #f7fcff;
padding: 7px 8px 5px 42px;
}
.message>.message-icon {
position: absolute;
color: #7b7b7b;
font-size: 26px;
left: 10px;
}
p {
color: #7b7b7b;
margin: 0 0 3px 0;
}
a {
color: #1464ae;
font-size: 12px;
text-decoration: none;
}
a .action-icon {
margin-left: 3px;
font-size: 10px;
}
<link rel="stylesheet" type="text/css" href="https://maxcdn.bootstrapcdn.com/font-awesome/4.7.0/css/font-awesome.min.css">
<div class="message">
<span class="message-icon"><i class="fa fa-exclamation-circle"></i></span>
<p>You are no longer on FPC, you will now be back to your regular contract.</p>
<a href="">Learn More
<span class="action-icon"><i class="fa fa-chevron-right"></i></span>
</a>
</div>

Navbar align part right part left errors

I'm trying to create a navbar with some items on the left and some items on the right (Item 1 on the left, items 2 and 3 on the right). My JSFiddle has my current code.
What I have tried to fix this issue:
float: right
text-align:right
None of them seem to work. I'm sure there is a super simple solution, but I just can't think of it.
HTML:
<div class="navbar">
<!--Create the button home -->
<p class="innav">Num1</p>
<p class="HL">|</p>
<p class="rightIn">Num2</p>
<p class="HL">|</p>
<p class="rightIn">NUM 3</p>
<p class="HL">|</p>
</div>
CSS:
div.navbar{
width:100%;
height: 30px;
background-color: #03572c;
}
p{
display: inline;
}
p.innav{
color:white;
font-size: 24px;
width: 30px;
height: 30px;
margin-left: 10px;
margin-top: 10px;
}
p.rightIn{
color:white;
font-size: 24px;
width: 30px;
height: 30px;
margin-left: 10px;
margin-top: 10px;
}
.HL{
margin-left: 10px;
color:white;
font-size:24px;
}
JSfiddle
Any help would be greatly appreciated! :)
Add these style to your css.
p.rightIn,
p:nth-child(4),
p:nth-child(6)
{
float: right;
margin: 0px 5px;
width: auto;
}
Jsfiddle
I would recommend that you use a CSS grid system for this, since you are likely to need this functionality over a over on your sites.
Here are some grid systems that I have used in the past:
Pure CSS
http://purecss.io/grids/
Foundation
http://foundation.zurb.com/docs/components/grid.html
Bootstrap
http://getbootstrap.com/css/#grid
Semantic UI
http://semantic-ui.com/collections/grid.html
Or, if you feel like creating your own grid system, here is a good article about it:
http://www.sitepoint.com/understanding-css-grid-systems/
nav {
background: #000000;
width: 100%;
display: block;
padding: 8px 0;
font-family: arial;
font-size: 13px;
}
nav span {
display:block;
width:100%;
line-height: normal;
text-align:right;
}
nav a {
color: #ffffff;
padding: 0 10px;
text-decoration: none;
display:inline-block;
border-right:1px solid #ffffff;
}
nav a:first-child{
float:left;
}
nav a:last-child{
border:none;
}
<nav>
<span>
Link 1
Link 2
Link 3
</span>
</nav>
Demo

Make the drop-down menu's width dynamic

My website uses a drop-down menu for the things you can do on the page.
HTML:
<table class="navbar">
<td class="menuNormal geometry" width="135px" onmouseover="menu('exp',this);" onmouseout="menu('col',this);">
<p class="tdesc">
<span lang="hu">Geometria</span>
<span lang="en">Geometry</span>
</p>
<div class="menuNormal dropdown" width="inherit">
<table class="menu" width="inherit">
<tr><td class="menuNormal">
<a href="javascript:geodesc('squa')" class="menuitem">
<span lang="hu">Négyzet</span>
<span lang="en">Square</span>
</a>
</td></tr>
...
</table>
</div>
</td>
</table>
CSS:
table {
padding:0;
margin:0;
}
table.navbar {
background-color: ButtonFace;
font: menu;
}
p.tdesc {
margin: 0;
padding: 0 3px 0 3px;
text-align:center;
font: menu;
}
table.menu{
font-size: 8pt;
margin: 0px;
padding: 0px;
}
td.menuNormal{
padding: 0px;
color: ButtonText;
vertical-align: top;
}
td.menuHover{
padding: 0px;
color: HighlightText;
vertical-align: top;
background-color: Highlight;
}
div.menuNormal{
display: none;
position: static;
}
div.menuHover{
border: 1.5px solid ButtonShadow;
background-color: Menu;
display: inline;
position: absolute;
}
a.menuitem:link{
text-decoration: none;
color: ButtonText;
padding: 2.5px;
border-bottom: 1px solid GrayText;
display: block;
}
a.menuitem:hover{
text-decoration: none;
color: HighlightText;
padding: 2.5px;
background-color: Highlight;
border-bottom: 1px solid GrayText;
display: block;
}
.hover {
border:3px ridge #8CA3FF;
background-color: #C9D4FF;
font-style:normal;
}
Currently, this solution is not the perfect one, since the menu's width is fixed, and when I tried to make it look like a bit more drop-down-ish, it extended the width of the top label when showing the actual options.
I need a method that I could use to make the options appear like an actual drop-down would, and make the label width fit the text that it contains.
If this is something new you are putting together and you have complete control over it and the goal is to make a nice website (not about showing an understanding of CSS) and you have no limitations such as not using an existing library, then I would suggest trying out Twitter Bootstrap and using a fluid container and navigation as a base and then add your own CSS on top for specific design changes if required.