How to make buttons next to each other? - html

I have two buttons where I tried to put next to each others but for some reason is not working right. Can anyone check out my CSS code below to see if everything okay, if not I will be thankful if anyone can fix it?
Here is my code:
<a class="back" href="#">Back</a>
<a class="delete" ng-click="">Confirm</a>
CSS
a.back, .delete {
background: #00b7ff;
box-shadow: 0 2px 5px rgba(0,0,0,0.1);
color: #fff;
display: block;
font-weight: bold;
margin: 0 0 20px;
padding: 14px 0;
text-align: center;
width: 200px;
}
a.back:hover {
background: #00b7ff;
text-decoration: none;
}

Change display: block; to display: inline-block;:
a.back,
.delete {
background: #00b7ff;
box-shadow: 0 2px 5px rgba(0, 0, 0, 0.1);
color: #fff;
display: inline-block;
font-weight: bold;
margin: 0 0 20px;
padding: 14px 0;
text-align: center;
width: 200px;
}
a.back:hover {
background: #00b7ff;
text-decoration: none;
}
<a class="back" href="#">Back</a>
<a class="delete" ng-click="">Confirm</a>

Change display: block;
to display: flex;

you can use display flex to organise your buttons for more information go to this link here

You may encounter mysterious white space between buttons if you use inline blocks as the accepted answer suggests. It is caused by natural white space between inline elements (imagine the white spaces between letters). To remove it, the simplest way is to put the ending tag and beginning together, such as:
<a class="back" href="#">Back
</a><a class="delete" ng-click="">Confirm</a>
There are several other methods, but I found this one the easiest. To learn more, check this good article.

Related

Website button underline won't go away, how can I fix this?

I'm quite new to web development and am making a website for myself. I've come across an issue regarding buttons on my website where the text underline for a button doesn't go away. For some reason, even after applying text-decoration: none !important; it's still there.
A bit of background on what I'm trying to do
I've added two buttons that look the same, but they link to different things. This is because I want the links to change on mobile. In the CSS media query I've specified which button displays on mobile devices. The original buttons are fine, but the ones I want to use on mobile devices have a purple underline for some reason.
I'd love some help to have this sorted out because the underline makes the button look a bit odd when displayed on mobile. I've attached some images and code for one of the buttons below.
Images:
Code:
This is the HTML for a pair of the buttons:
<div class="cont3_left_wrapper">
<h2 class="hd2_1">Header Text</h2>
<p>
Body Text
</p>
<a href="#/" id="header_button_3">
<button type="button" class="btn_chat">Let's Chat</button>
</a>
<a href="#/" id="header_button_3_mob">
<button type="button" class="btn_chat_mob" onClick="location.href='contact.html'">Let's Chat</button>
</a>
</div>
This is the CSS for the buttons:
.btn_chat {
padding: 13px 0 11px 0;
background-color: #E84855;
border-radius: 4px;
border: none;
text-decoration: none;
text-align: center;
font-size: 24px;
font-weight: 700;
color: white;
box-shadow: 0px 2.0407px 20.407px rgba(0, 0, 0, 0.25);
margin-top: 35px;
width: 270px;
}
.btn_chat_mob {
display: none;
padding: 13px 0 11px 0;
background-color: #E84855;
border-radius: 4px;
border: none;
text-align: center;
font-size: 24px;
font-weight: 700;
color: white;
box-shadow: 0px 2.0407px 20.407px rgba(0, 0, 0, 0.25);
margin-top: 35px;
width: 270px;
}
#media screen and (max-width: 480px) {
.btn_chat {
display: none;
width: 100%;
}
.btn_chat_mob {
display: block;
width: 100%;
text-decoration: none !important;
}
}
.btn_chat_mob {
display: inline-block;
width: 100%;
}
Since Your button is inside [a tag] and it has underlined as default CSS you should apply following CSS to [a tag] also it should work..
a {
text-decoration: none;
outline: none;
}
a:hover {
outline: none;
}
a:focus {
outline: none;
}

How to move underline using border-bottom to make it look like a underline using box-shadow inset?

Simple question:
Can I make the underline using border-bottom (the ones on the right side) look exactly like the ones using box-shadow (the ones on the left side)?
I need it to be CSS only. And it may span across multiple lines as you can see from the snippet.
Basically I need to move the border-bottom a little bit up and not mess with everything else.
#import url('https://fonts.googleapis.com/css?family=Proxima+Nova');
div.flex {
display: flex;
width: 420px;
justify-content: space-between;
}
div.flex2 {
display: flex;
width: 300px;
justify-content: space-between;
}
h2 {
font-family: 'Proxima Nova';
color: rgb(60,128,124);
font-size: 21px;
font-weight: bold;
margin-top: 20px;
margin-bottom: 10px;
}
a.boxShadow {
color: darkGrey;
text-decoration: none;
line-height: 26px;
box-shadow: inset 0 -2px white, inset 0 -4px 0 rgb(60,128,124);
padding-bottom: 3px;
}
a.borderBottom {
color: darkGrey;
text-decoration: none;
line-height: 26px;
border-bottom: 2px solid rgb(60,128,124);
}
<div class="flex">
<h2>
<a class="boxShadow">Hello gjq box-shadow</a>
</h2>
<h2>
<a class="borderBottom">Hello border-bottom</a>
</h2>
</div>
<div class="flex2">
<h2>
<a class="boxShadow">Hello gjq box-shadow</a>
</h2>
<h2>
<a class="borderBottom">Hello border-bottom</a>
</h2>
</div>
REASON FOR THIS QUESTION (BROWSER CONSISTENCY):
The box-shadow example does exactly what I want, but it does not look good on Edge (and I'm afraid other browsers might not render it properly as well). It looks perfect on recente versions of Chrome, Firefox and Safari though.
On Edge, the box-shadow example looks like this (see small line leaking at the bottom):
On the other hand, border-bottom seems to render consistently across browsers. But I can't get the underline in the position that I need.
Gradient can do this
#import url('https://fonts.googleapis.com/css?family=Proxima+Nova');
div.flex {
display: flex;
width: 420px;
justify-content: space-between;
}
div.flex2 {
display: flex;
width: 300px;
justify-content: space-between;
}
h2 {
font-family: 'Proxima Nova';
color: rgb(60,128,124);
font-size: 21px;
font-weight: bold;
margin-top: 20px;
margin-bottom: 10px;
}
a.boxShadow {
color: darkGrey;
text-decoration: none;
line-height: 26px;
box-shadow: inset 0 -2px white, inset 0 -4px 0 rgb(60,128,124);
padding-bottom: 3px;
}
a.borderBottom {
color: darkGrey;
text-decoration: none;
line-height: 26px;
background:
linear-gradient(rgb(60,128,124),rgb(60,128,124))
bottom 1px center/ /* Position */
100% 2px /*width height*/
no-repeat;
}
<div class="flex">
<h2>
<a class="boxShadow">Hello gjq box-shadow</a>
</h2>
<h2>
<a class="borderBottom">Hello border-bottom</a>
</h2>
</div>
<div class="flex2">
<h2>
<a class="boxShadow">Hello gjq box-shadow</a>
</h2>
<h2>
<a class="borderBottom">Hello border-bottom</a>
</h2>
</div>

This div's border is a floating line instead of an actual border

I might be missing something basic. It's so simple:
.items {
float: left;
font-family: 'Arial', sans-serif;
text-decoration: none;
color: black;
font-size: 30px;
margin: 25px 30px 0px 0px;
}
.langswitch {
border: 3px solid #86D1DA;
border-radius: 5px;
}
<a href="#" class="langswitch">
<div class="items">Italiano</div>
</a>
jsFiddle
Moving the class from the anchor to the div will make it (the border) disappear all together.
Well, your <a class="lamgswitch"> does not have any content... The float: left; makes the <div class="items">float out of it...
So try to remove it, and replace it with display: inline-block;, as the div is a block component, and you placed it inside an inline component (a)...
.items {
display: inline-block;
font-family: 'Arial', sans-serif;
text-decoration: none;
color: black;
font-size: 30px;
margin: 25px 30px 0px 0px;
}
.langswitch {
border: 3px solid #86D1DA;
border-radius: 5px;
}
<a href="#" class="langswitch">
<div class="items">Italiano</div>
</a>
Place the <a> tag inside the <div> rather than the other way around.
.items{
float: left;
font-family: 'Arial', sans-serif;
text-decoration: none;
color: black;
font-size: 30px;
margin: 25px 30px 0px 0px ;
}
.langswitch{
border: 3px solid #86D1DA;
border-radius: 5px;
}
<div class="items">Italiano</div>
Hope this helps.
Technically, placing the <a> inside the <div> is the semantically correct way to do this as described in the other answer.
If you really HAVE to do it this way, you need to change the display of the <a> tag from inline to inline-block.

Extra Padding on my site using ProfitBuilder WP

I am currently copying this site: http://www.onlinemeetingnow.com/register/?id=q6wpivs95c& here: http://beaminggeek.com/profitbuilder/test-2/
and using a WP tool called ProfitBuilder: http://wpprofitbuilder.com/
I have three issues here in particular.
1. I put margin-top: 20px; on my tag (to push it on the center) on the image below however when I do it adds up a margin on the both top and below:
Here's my code on that:
<h2 style="text-align: center; font-size: 40px; font-weight: bold;"><span style="color: #ffffff; ">The 4-Step Strategy We Used to Build a</span><br /> <span style="color: #ffffff;"> 7-Figure Coaching Business...</span><br /> <span style="color: #ffffff; font-size: 25px; "> (while ignoring ALL the conventional wisdom!)</span></h2><p style="text-align: center;"><a style="font-family: 'Open Sans Condensed'; text-shadow: 1px 1px 1px rgba(0,0,0,0.3); filter: progid:DXImageTransform.Microsoft.gradient(startColorstr='#ffd800',endColorstr='#f7d100'); background: -moz-linear-gradient(center top,#ffd800 5%,#f7d100 100%); background-color: #ffd800; display: block; margin: 0 auto; position: relative; min-height: 33px; width: 280px; text-decoration: none; font-weight: bold; font-size: 30px; color: #fdffff; cursor: pointer; border-radius: 3px; -webkit-border-radius: 3px; -moz-border-radius: 3px; border: none; padding: 17px 10px; text-align: center; z-index: 2; margin-top: 12px;" href="#">Claim My Spot Now >></a></p>
I also have some issues with this two section here as there are spaces all around:
Any idea what to move to make it look perfect using inline-CSS? YOu can use Chrome inspector tool to check this.
NOTE: The Profit Builder Tool is a tool that doesnt go with custom css panel with it meaning everything is just plain inline CSS.
You have a padding-bottom set for your Claim Your Spot Now button. So when you put a margin-top value on top of your h2 it pushes your p down as well and the padding-bottom of the p pushes down the following section
I think this should work
body {
margin: -1px 0 0 0
}
h2 {
margin: 25px 0 0 0;
}
.pbuilder_column {
margin: 0 0 -24px 0
}

HTML content on new lines has overlapping background effect

Below is my problem, these are the same link and the orange background is a hover effect set in css. As you can see when the window is compressed the text of the link moves onto the next lines to fit the screen. But the background effect of each line obscures the second. I can set the display to be block, but that would stretch the background to 100% of the window, which isn't what I want when the page is not narrow.
Thanks in advance
EDIT: CODE
<div class="PageSection">
<a class="LinkButton" href="">This Is My Link, There Are Many Like It But This One Is Mine</a>
</div>
.PageSection {
width: 100%;
margin: 50px 0px 50px 0px;
text-align: center;
font-size: 30px;
}
input[type="button"],
input[type="submit"],
.LinkButton {
padding: 5px 10px 5px 10px;
cursor: pointer;
color: inherit;
font-size: inherit;
text-decoration: none;
line-height: 100%;
border: none;
background-color: transparent;
}
input[type="button"]:hover,
input[type="submit"]:hover,
.LinkButton:hover {
background-color: #FF5A19;
}
EDIT:
I know I could set the line-height css property, but that gives the link ugly spacing, and I am also aiming for a square block of background colour, just not to the full width of the page.
assuming your padding is for creating that extra block effect.
try
.PageSection {
width: 100%;
margin: 50px 0px 50px 0px;
text-align: center;
font-size: 30px;
}
input[type="button"],
input[type="submit"],
.LinkButton {
/*padding: 5px 0 5px 0;*/
cursor: pointer;
color: inherit;
font-size: inherit;
text-decoration: none;
line-height: 100%;
border: none;
background-color: transparent;
background-clip: padding-box;
}
input[type="button"]:hover,
input[type="submit"]:hover,
.LinkButton:hover {
background-color: #FF5A19;
box-shadow: 10px 0 0 0px #FF5A19,-10px 0 0 0px #FF5A19;
}
all you need on the link is background-clip: padding-box; on the link and some box-shadow to cover the extra bit where padding can't reach due to inline element behaviour.
Edit: JSFiddle
I think i have managed to do what you wanted, do you want it multi-lined even on full width or when page width is smaller
I have used multiple spans tags to controls the lines
<div class="PageSection">
<a class="LinkButton" href=""><span>This Is My Link, </span> <span> There Are Many Like </span> <span> It But This One Is Mine </span></a>
</div>
here is the fiddle on what i have achieved
I HAVE UPDATED THE FIDDLE to your desired outcome
See the FIDDLE here