how to clear black dash in html button? - html

I don't know how to describe my problem but look at my output you'll get an idea. I
googled about my problem but i couldn't found the solution.
.btn1 {
font-family: 'Times New Roman', Times, serif;
margin-right: 0px;
width: 100px;
height: 30px;
font-size: 17px;
font-weight: 200;
background-color: #f7e7e7;
color: rgb(49, 126, 126);
border-radius: 5px;
border: 1px solid rgb(186, 230, 173);
box-shadow: 3px 3px rgb(98, 151, 98);
}
<div>
<a href="#">
<button class="btn1">Home</button>
</a>
<a href="product.html">
<button class="btn2">Products</button>
</a>
<a href="#">
<button class="btn3">Buy Now</button>
</a>
<a href="findus.html">
<button class="btn4">Find us</button>
</a>
</div>
Every button have same code in CSS.
Can you please tell, what am i doing wrong?
Thank you.

You have unnecessarily wrapped each of your <button>s in an <a> tag and this is the browser's default underline style of the <a> tag that you can see.
Note: Some of the other answers suggest simply hiding the underline, but wrapping a <button> in an <a> is considered to be an anti-pattern that should be avoided.
Links
.btn1 {
font-family: 'Times New Roman', Times, serif;
margin-right: 0px;
width: 100px;
height: 30px;
font-size: 17px;
font-weight: 200;
background-color: #f7e7e7;
color: rgb(49, 126, 126);
border-radius: 5px;
border: 1px solid rgb(186, 230, 173);
box-shadow: 3px 3px rgb(98, 151, 98);
text-decoration: none;
}
<div>
<a class="btn1" href="#">Home</a>
<a class="btn1" href="product.html">Products</a>
<a class="btn1" href="#">Buy Now</a>
<a class="btn1" href="findus.html">Find us</a>
</div>
Buttons
.btn1 {
font-family: 'Times New Roman', Times, serif;
margin-right: 0px;
width: 100px;
height: 30px;
font-size: 17px;
font-weight: 200;
background-color: #f7e7e7;
color: rgb(49, 126, 126);
border-radius: 5px;
border: 1px solid rgb(186, 230, 173);
box-shadow: 3px 3px rgb(98, 151, 98);
}
<div>
<button class="btn1">Home</button>
<button class="btn2">Products</button>
<button class="btn3">Buy Now</button>
<button class="btn4">Find us</button>
</div>
You can read about links vs buttons, and why you might choose one over the other here.

The dashes you are seeing are actually the default underline that accompanies anchor elements. All you need to add is:
a {
text-decoration: none;
}
That being said, nesting button elements inside of anchor elements is invalid HTML and should be avoided.

Replace a with button or use css rule text-decoration: none

.btn {
font-family: "Times New Roman", Times, serif;
margin: 10px;
padding:10px;
width: 100px;
height: 30px;
font-size: 17px;
font-weight: 200;
background-color: #f7e7e7;
color: rgb(49, 126, 126);
border-radius: 5px;
border: 1px solid rgb(186, 230, 173);
box-shadow: 3px 3px rgb(98, 151, 98);
}
a
{
text-decoration:none;
color: black;
}
<div>
<a href="#" class="btn">
Home
</a>
<a href="product.html" class="btn">
Product
</a>
<a href="#" class="btn">
buy now
</a>
<a href="findus.html" class="btn">
find us
</a>
</div>

Related

This button's "padding" makes no sense

I was trying to make a button with a red border thats in the bottom and in the middle, but, its padding doesn't let me! You can see with the border, its like 100% width, it makes no sense.
Ive tried everything, the only "solution" i found, was to set the margins to something like 200px, but the hitbox is still massive in the x axis, if someone knows what might becausing this i'd appreciate an answer, thank you!!
HTML:
<div class="message">
<h1>NA CONJUGAÇÃO DO COMPROMISSO, DO ACOMPANHAMENTO E DA ATENÇÃO.</h1>
<h3>A colaboração de todos é fundamental para a concretização dos pressupostos de uma escola que todos queremos.</h3>
</div>
<div class="button">
<a href="example.com">
<div class="ano-letivo">Ano Letivo</div>
</a>
</div>
CSS:
h1 {
font-family: 'Abril Fatface', cursive;
color: white;
text-align: center;
padding: 80px 300px 5px;
font-size: 60px;
text-shadow: 0px 2px 3px black;
}
h3 {
font-family: 'Roboto Slab', serif;
color: white;
text-align: center;
text-shadow: 0px 2px 3px black;
}
.ano-letivo {
text-align: center;
color: white;
font-weight: 600;
padding: 10px;
border: 3px solid rgb(255, 69, 59);
}
How it looks: (except background)
A commenter correctly points out that you should probably change your element from div to button. However, if for some reason you need to keep the element as-is, adding the following CSS rules should center it:
width: fit-content;
margin: 0 auto;
display: block;
Here's a demo:
h1 {
font-family: 'Abril Fatface', cursive;
color: white;
text-align: center;
padding: 80px 300px 5px;
font-size: 60px;
text-shadow: 0px 2px 3px black;
}
h3 {
font-family: 'Roboto Slab', serif;
color: white;
text-align: center;
text-shadow: 0px 2px 3px black;
}
.ano-letivo {
font-weight: 600;
padding: 10px;
border: 3px solid rgb(255, 69, 59);
width: fit-content;
margin: 0 auto;
display: block;
}
<div class="button">
<a href="example.com">
<div class="ano-letivo">Ano Letivo</div>
</a>
</div>

Why can't I style anchor elements?

This is all my code (the code seems very messy because I just started learning about 2/3 weeks ago). I cant seem to style the anchor elements. I even tried putting a class on them and it also doesn't works. I'm kinda new to this thing.
#import url('https://fonts.googleapis.com/css2?family=Bebas+Neue&display=swap');
#import url('https://fonts.googleapis.com/css2?family=Merriweather:wght#700&display=swap');
#import url('https://fonts.googleapis.com/css2?family=Bree+Serif&display=swap');
#import url('https://fonts.googleapis.com/css2?family=Inter:wght#500&display=swap');
body {
height: 100%;
margin: 0;
padding: 0;
background: #bbb;
}
.ex-house {
padding: 0;
display: block;
margin: 0 auto;
max-height: 100%;
max-width: 100%;
opacity: 0.8;
}
.house-dh {
position: absolute;
top: -20%;
left: 2%;
padding: 0px;
margin: 0px;
color: rgb(255, 255, 255);
font-family: 'Bree serif';
font-size: 125px;
text-align: center;
text-shadow: 2px 2px 3px rgba(255, 255, 255, 0.1);
}
.about-gnco1 {
position: absolute;
color: rgb(255, 255, 255);
font-family: 'Inter';
font-size: 35px;
text-align: left;
margin: 0px;
padding: 0px;
left: 2%;
top: 20%;
text-shadow: 2px 2px 3px rgba(255, 255, 255, 0.1);
}
/* this is my code for the style element i think i did it right but when i run it. the a href element dosent change */
.front-button {
font-family: 'Bebas Neue';
font-size: 20px;
color: white;
text-shadow: 2px 2px 3px rgba(255, 255, 255, 0.1);
}
.front-button a {
margin: 0 20px;
}
<body>
<div class="front">
<img class="ex-house" src="https://via.placeholder.com/80" alt="dreamhouse">
<div class="house-dh">
<p>grandnew.co</p>
</div>
<div class="about-gnco">
<p class="about-gnco1">Is here to help you<br> build your own<br> Dream House.</p>
</div>
</div>
</div>
<div class="front-button">
CUSTOMIZE
DESIGNS
PLANS
ABOUT US
</div>
</body>
if you mean underline of link for that you can use the method text-decoration for examplea{text-decoration:none} this code will remove any decorations of a tag so if you wanna use this function for all a tags you will write a{text-decoration:none} so if you wanna set decoration of specific tag you can give a class on the tag before you can change something example
HTML
go to stackoverflow
<a class="a-tag" href="https://stackoverflow.com">go to stackoverflow</a>
CSS
a{ //for all <a> tags
text-decoration:none
}
.a-tag{ // only for tag who have the a-tag class
text-decoration:none
color:black;
}
This works for me. The style of the text in the '.front-button a', not in '.front-button'
.front-button a {
margin: 0 20px;
font-family: 'Bebas Neue';
font-size: 20px;
color: red;
text-shadow: 2px 2px 3px rgba(241, 238, 53, 0.5);
}
link style
More about link styles:
https://www.w3schools.com/css/css_link.asp
How do I change link style in CSS?

HTML / CSS: how to style a Div such that it matches the styling/behavior of Bootstrap buttons

I have a webpage that uses Bootstrap's button class="btn btn-sm btn-outline-primary".
On the same page, I render a Div with JavaScript that's clickable. I assign it an orders-data class:
...
element.classList.add('orders-data');
I would like to get the Div to match the styling of the buttons using some CSS. This is what I have so far:
CSS
.orders-data {
border: 1px solid #007bff;
border-radius: 5px;
margin-top: 5px;
padding-left: 10px;
}
.orders-data:hover {
background-color: #007bff;
border: 1px solid #007bff;
color: white;
border-radius: 5px;
margin-top: 5px;
padding-left: 20px;
This seems to work. But, is there a more elegant way to do this?
Thanks!
You can use this style to make Div element similar to Bootstrap Button.
.orders-data {
cursor:pointer;
color: #fff;
background-color: #007bff;
border-color: #007bff;
border: 1px solid transparent;
padding: .375rem .75rem;
font-size: 1rem;
line-height: 1.5;
border-radius: .25rem;
transition: color .15s ease-in-out,background-color .15s ease-in-out,border-color .15s ease-in-out,box-shadow .15s ease-in-out;
user-select: none;
display: inline-block;
font-weight: 400;
}
.orders-data:hover {
color: #fff;
background-color: #0069d9;
border-color: #0062cc;}
You can add this styling to the div:
.orders-data {
display: block;
width: 115px;
height: 25px;
padding: 10px;
text-align: center;
border-radius: 5px;
color: white;
font-weight: bold;
line-height: 25px;
background-color: #0d6efd;
border-color: #0d6efd;
}
.orders-data:hover {
background-color: #007bff;
border: 1px solid #007bff;
color: white;
border-radius: 5px;
margin-top: 5px;
padding-left: 20px;
}
<div class="orders-data"></div>
This looks more like the button you want:
.orders-data {
display: inline-block;
border: 1px solid transparent;
background-color: rgb(239, 239, 239);
border-radius: 3px;
line-height: 1.5;
font-size: 12px;
padding: 5px 10px;
text-align: center;
cursor: pointer;
}
.orders-data:active{
outline:5px auto rgb(14,98,201) ;
}
<div class='orders-data'>
Bootstrap Button
</div>
welcome here bro,
this is work without any problems but you can take more fast way than this
you can just add the button classes for div this classes global in bootstrap you can use it in any element you want like
<link href="https://cdnjs.cloudflare.com/ajax/libs/twitter-bootstrap/5.0.2/css/bootstrap.min.css" rel="stylesheet" />
<button class="btn btn-sm btn-outline-primary"> button</button>
<div class="btn btn-sm btn-outline-primary">
button
</div>
because of : element.classList.add('orders-data'); you use,
You can add the bootstrap classes to your element going through a loop, so need to write them again.
exemple to demonstrate the idea :
let el = document.querySelector('a');
const classS = ['btn', 'btn-sm', 'btn-outline-primary'];
for (i = 0; i < classS.length; i++) {
el.classList.add(classS[i])
}
.shadow {
box-shadow: 2px 2px 2px black
}
<link href="https://cdnjs.cloudflare.com/ajax/libs/twitter-bootstrap/5.0.2/css/bootstrap.min.css" rel="stylesheet" />
<button class="btn btn-sm btn-outline-primary">hello</button>
<a class="shadow" href="#">the world</a>
(if your element has no other class, then setAttribute at once will do):
let el = document.querySelector('a');
el.setAttribute('class','btn btn-sm btn-outline-primary' ) ;
.shadow {
box-shadow: 2px 2px 2px black
}
<link href="https://cdnjs.cloudflare.com/ajax/libs/twitter-bootstrap/5.0.2/css/bootstrap.min.css" rel="stylesheet" />
<button class="btn btn-sm btn-outline-primary">hello</button>
<a class="shadow" href="#">the world</a>
<p><code>setAttribute()</code> removes any value already there , shadow class is not there anymore!</p>

ignoring whitespace and not working

I am trying to increase the space between the image and text in this link top bar.
Link: https://pushdaddy2.myshopify.com/
I tried which is normal to use for increasing the whitespace but it just prints the character.
<span id="pab_message" style="color:inherit;">&nbsp;&nbsp;All t-shirts are 15% off </span>
Can anyone say is there any criteria to use ?
Here is the complete html:
<div id="pab_bar" style="text-align: center; margin: 0px; padding: 4px 10px;
left: 0px; height: auto; width: 100%; box-sizing: border-box; border: none;
background-color: rgb(34, 34, 34); color: rgb(255, 246, 169); font-size: 20px;
line-height: 25px; font-family: Sacramento;">
<div id="pab_content" style="text-align:center; display: inline-block;">
<img src="https://img.pngio.com/truck-icon-myiconfinder-png-of-transportation-vehicles-256_256.png"
width="30" style="vertical-align:middle">
<span id="pab_message" style="color:inherit;">All t-shirts are 15% off </span>
<img src="" width="30" style="vertical-align:middle">
<span style="display:inline-block;">
<a id="pab_button" style="outline: none; border: none; line-height: 2em;
padding: 0px 1em; margin: 0px 0px 0px 1em; display: inline-block;
border-radius: 0.25em; cursor: pointer; width: auto;
height: inherit; font-family: inherit; font-size: 0.875em;
text-align: center; text-decoration: none;
-webkit-appearance: none; color: rgb(255, 246, 169);
background-color: rgb(0, 0, 0);" type="button" href="#"
onclick="pab_button_on_click(event)">Check the product</a>
</span>
</div>
</div>
"I tried which is normal to use for increasing the whitespace but it just prints the character."
No it's not, that's what padding is for.
#pab_message {
padding-left: 2rem;
}
<div id="pab_bar" style="text-align: center; margin: 0px; padding: 4px 10px; left: 0px; height: auto; width: 100%; box-sizing: border-box; border: none; background-color: rgb(34, 34, 34); color: rgb(255, 246, 169); font-size: 20px; line-height: 25px; font-family: Sacramento;">
<div id="pab_content" style="text-align:center; display: inline-block;"><img src="https://img.pngio.com/truck-icon-myiconfinder-png-of-transportation-vehicles-256_256.png" width="30" style="vertical-align:middle"> <span id="pab_message" style="color:inherit;">All t-shirts are 15% off </span><img src="" width="30" style="vertical-align:middle"> <span style="display:inline-block;"><a id="pab_button" style="outline: none; border: none; line-height: 2em; padding: 0px 1em; margin: 0px 0px 0px 1em; display: inline-block; border-radius: 0.25em; cursor: pointer; width: auto; height: inherit; font-family: inherit; font-size: 0.875em; text-align: center; text-decoration: none; -webkit-appearance: none; color: rgb(255, 246, 169); background-color: rgb(0, 0, 0);" type="button" href="#" onclick="pab_button_on_click(event)">Check the product</a></span></div>
</div>
Continuing #Paulie_D's answer. And your comment. If you want manual spaces just use inline spacing with different padding values.
<span id="pab_message" style="color:inherit; padding-left: 10px;">All t-shirts are 15% off </span>
<span id="pab_message" style="color:inherit; padding-left: 15px;">All t-shirts are 15% off </span>
<span id="pab_message" style="color:inherit; padding-left:20px;">All t-shirts are 15% off </span>
AND to your answer that why non breaking space doesn't work at the beginning of the sentence you can look at:
https://stackoverflow.com/a/12279649/9357872
or read this from https://www.w3schools.com/html/html_entities.asp:
Non-breaking Space
A common character entity used in HTML is the non-breaking space:
A non-breaking space is a space that will not break into a new line.
Two words separated by a non-breaking space will stick together (not
break into a new line). This is handy when breaking the words might be
disruptive.
Examples:
§ 10
10 km/h
10 PM
Another common use of the non-breaking space is to prevent browsers
from truncating spaces in HTML pages.
If you write 10 spaces in your text, the browser will remove 9 of
them. To add real spaces to your text, you can use the
character entity.

How to center align text horizontally and VERTICALLY in a box/container?

I am trying to create a web page that looks like this:
Download page
I worked with bootstrap and created rows to align three download options next to each other. I then created containers in these rows (to replicate the boxes) and center aligned the text and download icon horizontally. Unfortunately, I am not sure how to center align the text and icon vertically in a container. Can anyone help out? My current design looks like this:
My code is the following:
.download {
font: Verdana, Helvetica, Arial, sans-serif;
color: RGB(112, 112, 112);
font-size: 18px;
text-align: center;
padding: 5px;
}
.download:hover {
color: rgb(227, 111, 30);
cursor: pointer;
}
#download-icon {
font-size: 80px;
float: left;
}
.container-border {
border-style: solid;
border-color: rgb(0, 143, 197);
padding: 5px;
min-height: 120px;
}
<div class="container">
<div class="row">
<div class="col-xs-4">
<div class="container-border">
<i class="material-icons" style="color:rgb(0,143,197);" id="download-icon">file_download</i>
<p class="download"> Download list of charities that have <b> not submitted </b> data yet </p>
</div>
</div>
</div>
</div>
Edit: Thanks everyone for their answers! I really appreciate them. For me it worked by simply adjusting my content-border class with:
.container-border {
border-style: solid;
border-color: rgb(0, 143, 197);
padding: 5px;
min-height: 120px;
display: flex;
align-items: center;
/* vertical center */
}
You don't need to complicate stuff using FlexBox. Please use something like this, a table layout or line-height and vertical-align combination:
.download {
font: Verdana, Helvetica, Arial, sans-serif;
color: RGB(112, 112, 112);
font-size: 18px;
text-align: center;
padding: 5px;
}
.download:hover {
color: rgb(227, 111, 30);
cursor: pointer;
}
#download-icon {
font-size: 80px;
vertical-align: middle;
line-height: 120px;
}
#download-icon + span {
vertical-align: middle;
line-height: 1;
}
.container-border {
border-style: solid;
border-color: rgb(0, 143, 197);
padding: 5px;
min-height: 120px;
}
<link href="https://fonts.googleapis.com/icon?family=Material+Icons" rel="stylesheet">
<div class="container">
<div class="row">
<div class="col-xs-4">
<div class="container-border">
<i class="material-icons" style="color:rgb(0,143,197);" id="download-icon">file_download</i>
<span class="download"> Download list of charities that have <b> not submitted </b> data yet </span>
</div>
</div>
</div>
</div>
Preview
I would use a flexbox for the container-border class. In that case you can remove the floats.
.download {
font: Verdana, Helvetica, Arial, sans-serif;
color: RGB(112, 112, 112);
font-size: 18px;
padding: 5px;
text-align: center;
}
.download:hover {
color: rgb(227, 111, 30);
cursor: pointer;
}
#download-icon {
font-size: 80px;
}
.container-border {
border-style: solid;
border-color: rgb(0, 143, 197);
padding: 5px;
min-height: 120px;
display: flex;
align-items: center;
/* vertical center */
}
<link href="https://fonts.googleapis.com/icon?family=Material+Icons" rel="stylesheet">
<div class="container">
<div class="row">
<div class="col-xs-4">
<div class="container-border">
<i class="material-icons" style="color:rgb(0,143,197);" id="download-icon">file_download</i>
<p class="download"> Download list of charities that have <b> not submitted </b> data yet </p>
</div>
</div>
</div>
</div>
add display: flex;align-items: center; to .container-border
.container-border{
border-style:solid;
border-color: rgb(0,143,197);
padding: 5px;
min-height:120px;
display: flex;
align-items: center;
}
Why not just set a padding:
.download {
font: Verdana,Helvetica,Arial,sans-serif;
color: RGB(112,112,112);
font-size:18px;
text-align:center;
/* padding: 5px; <- removed */
padding: 12px 5px 5px 5px; /* New */
}
#download-icon {
font-size:80px;
float:left;
padding-top: 10px; /* New */
}
.container-border {
border-style:solid;
border-color: rgb(0,143,197);
padding: 5px;
min-height:120px;
width: 300px; /* New*/
}
Demo:
.download {
font: Verdana,Helvetica,Arial,sans-serif;
color: RGB(112,112,112);
font-size:18px;
text-align:center;
/* padding: 5px; <- removed */
padding: 12px 5px 5px 5px; /* New */
}
.download:hover {
color: rgb(227,111,30);
cursor: pointer;
}
#download-icon {
font-size:80px;
float:left;
padding-top: 10px; /* New */
}
.container-border {
border-style:solid;
border-color: rgb(0,143,197);
padding: 5px;
min-height:120px;
width: 300px; /* New*/
}
<link href="https://fonts.googleapis.com/icon?family=Material+Icons" rel="stylesheet">
<div class="container">
<div class="row">
<div class="col-xs-4">
<div class="container-border">
<i class="material-icons" style="color:rgb(0,143,197);" id="download-icon">file_download</i>
<p class="download"> Download list of charities that have <b> not submitted </b> data yet </p>
</div>
</div>
</div>
</div>