I am working a web page for my wife and adding a PayPal checkout button, although not using their standard button. For some reason, this code works when I put it into a WordPress block, but not when I view the page in a browser? Tried multiple browsers.
.text-sizing {
font-size: 12px;
text-align: center;
padding: 0rem;
display: flex;
align-items: center;
}
.btn-wrapper {
text-align: center;
padding: 0.1rem;
display: flex;
align-items: center;
}
.btn {
display: inline-block;
text-decoration: none;
border-radius: 50px;
border: 0px solid #400779;
color:#400779;
background: white;
font-size: 7px;
cursor: pointer;
}
.btn:hover,
.btn:active {
display: inline-block;
text-decoration: none;
border-radius: 50px;
border: 0px solid #400779;
color:white;
background: #400779;
font-size: 7px;
cursor: pointer;
}
<div class="btn-wrapper">
<div class="btn-wrapper">
<form action="https://www.paypal.com/cgi-bin/webscr" method="post" target="_top">
<input type="hidden" name="cmd" value="_s-xclick">
<input type="hidden" name="hosted_button_id" value="XXXXXXXXXXXXXx">
<input type="submit" class="btn" value="Preorder Signed Copy">
</form>
</div>
</div>
So apparently I was using the wrong CSS tags. It should be 'input [type=XXX]'
<style>
input { text-align: center;
padding: 0.1rem;
display: flex;
align-items: center;
}
.input-wrapper {
text-align: center;
padding: 0.1rem;
display: flex;
align-items: center;
}
input[type=submit], input[type=submit]:active, input[type=submit]:focus {
display: inline-block;
text-decoration: none;
border-radius: 50px;
border: 0px solid #400779;
color:#400779;
background: white;
font-size: 7px;
cursor: pointer;
}
input[type=submit]:hover {
display: inline-block;
text-decoration: none;
border-radius: 50px;
border: 0px solid #400779;
color:white;
background: #400779;
font-size: 7px;
cursor: pointer;
}
</style>
Related
I'm brand new to HTML and CSS. I'm trying to center two form buttons. Here is my code:
* {
font-family: arial, sans-serif;
}
body {
display: flex;
align-items: column;
}
.buttons {
background-color: #f8f9fa;
border: 1px solid #f8f9fa;
border-radius: 4px;
font-size: 14px;
margin: 11px 4px;
padding: 0 16px;
line-height: 27px;
height: 36px;
min-width: 54px;
text-align: center;
cursor: pointer;
user-select: none;
display: inline-block;
}
.search_area {
display: flex;
color: rgba(0, 0, 0, .87);
border: 1px solid #ddd;
width: 100%;
height: 34px;
font-size: 16px;
border-radius: 25px;
}
nav {
display: flex;
margin-right: 30px;
margin-top: 15px;
}
.search_box {
text-align: center;
display: block;
}
<!DOCTYPE html>
<html lang="en">
<head>
<title>Google</title>
<link rel="stylesheet" href="google.css">
</head>
<body>
<nav>
Image Search
Advanced Search
</nav>
<form class="search" action="https://www.google.com/search">
<img id="logo" src="logo.png" alt="Google logo">
<div>
<input name="q" type="text" class="search_area">
</div>
<input type="submit" value="Search Google" class="buttons">
<input type="submit" value="I'm Feeling Lucky" class="buttons">
</form>
</body>
</html>
As you can see, the two buttons beneath the search bar are justified to the left. I thought that text-align: center is the solution. But, this doesn't seem to work.
How do I get these two buttons to center on the screen?
Thanks in advance!
A sample update:
<html lang="en"><head>
<title>Google</title>
<link rel="stylesheet" href="google.css">
</head>
<body>
<nav>
Image Search
Advanced Search
</nav>
<form class="search" action="https://www.google.com/search">
<div style="
"><img id="logo" src="logo.png" alt="Google logo" style=""></div>
<div style="">
<div style="display: flex;align-content: center;">
<input name="q" type="text" class="search_area">
</div>
<div style="">
<input type="submit" value="Search Google" class="buttons">
<input type="submit" value="I'm Feeling Lucky" class="buttons">
</div>
</div>
</form>
</body></html>
CSS:
*{
font-family: arial, sans-serif;
}
body {
/*display: flex;
align-items: column;*/
}
.buttons {
background-color: #f8f9fa;
border: 1px solid #f8f9fa;
border-radius: 4px;
font-size: 14px;
margin: 11px 4px;
padding: 0 16px;
line-height: 27px;
height: 36px;
min-width: 54px;
text-align: center;
cursor: pointer;
user-select: none;
display: inline-block;
}
.search_area {
display: flex;
color: rgba(0, 0, 0, .87);
border: 1px solid #ddd;
width: 100%;
height: 34px;
font-size: 16px;
border-radius: 25px;
}
nav {
display: flex;
margin-right: 30px;
margin-top: 15px;
}
form{
display: table;
margin-left: auto;
margin-right: auto;
}
.search_box {
text-align: center;
display: block;
}
Use this CSS code:
Just paste it and see the changes.
I have commented the body section and it worked.
*{
font-family: arial, sans-serif;
}
body {
/*display: flex;
align-items: column;*/ /*I have commented the body CSS lines*/
}
.buttons {
background-color: #f8f9fa;
border: 1px solid #f8f9fa;
border-radius: 4px;
font-size: 14px;
margin: 11px 4px;
padding: 0 16px;
line-height: 27px;
height: 36px;
min-width: 54px;
text-align: center;
cursor: pointer;
user-select: none;
display: inline-block;
}
.search_area {
display: flex;
color: rgba(0, 0, 0, .87);
border: 1px solid #ddd;
width: 100%;
height: 34px;
font-size: 16px;
border-radius: 25px;
}
nav {
display: flex;
margin-right: 30px;
margin-top: 15px;
}
form{
display: table;
margin-left: auto;
margin-right: auto;
}
.search_box {
text-align: center;
display: block;
}
In your body tags don't use display: flex because when you used display flex then text-align: center wouldn't work. In your form tag you have a .search class. for centerizing i used .search { margin: 0 auto; width: 50%}
This is HTML code:
<!DOCTYPE html>
<html lang="en">
<head>
<title>Google</title>
<link rel="stylesheet" href="google.css">
</head>
<body>
<nav>
Image Search
Advanced Search
</nav>
<form class="search" action="https://www.google.com/search">
<img id="logo" src="logo.png" alt="Google logo">
<div>
<input name="q" type="text" class="search_area">
</div>
<div class="button">
<input type="submit" value="Search Google" class="buttons">
<input type="submit" value="I'm Feeling Lucky" class="buttons">
</div>
</form>
</body>
</html>
And here is Css:
*{
font-family: arial, sans-serif;
}
/* body{display: flex;align-items: column;} */
.buttons {
background-color: #f8f9fa;
border: 1px solid #f8f9fa;
border-radius: 4px;
font-size: 14px;
margin: 11px 4px;
padding: 0 16px;
line-height: 27px;
height: 36px;
min-width: 54px;
text-align: center;
cursor: pointer;
user-select: none;
display: inline-block;
}
.button{
text-align: center;
}
.search_area {
color: rgba(0, 0, 0, .87);
border: 1px solid #ddd;
width: 100%;
height: 34px;
font-size: 16px;
border-radius: 25px;
}
.search{
margin: 0 auto;
width: 50%;
}
nav {
display: flex;
margin-right: 30px;
margin-top: 15px;
}
.search_box {
text-align: center;
display: block;
}
I'm seeing some unexpected behavior from the following HTML/CSS code:
CSS
*{
font-family: arial, sans-serif;
padding: 0px;
margin: 0px;
}
body {
display: flex;
align-items: column;
flex-direction: column;
}
nav {
display: flex;
align-items: center;
justify-content: flex-end;
margin-right: 30px;
margin-top: 15px;
}
nav a {
font-size: 13px;
color: rgba(0, 0, 0, .87);
text-decoration: none;
cursor: pointer;
padding: 7px;
}
nav a:hover {
text-decoration: underline;
}
.buttons {
background-color: #f8f9fa;
border: 1px solid #f8f9fa;
border-radius: 4px;
font-size: 14px;
margin: 11px 4px;
padding: 0 16px;
line-height: 27px;
height: 36px;
min-width: 54px;
text-align: center;
cursor: pointer;
user-select: none;
display: inline-block;
margin-top: 30px;
}
.buttons:hover {
box-shadow: 0 1px rgb(0 0 0 / 10%);
background-color: #f8f9fa;
border: 1px solid #dadce0;
color: #202124;
}
.search_input_area {
background-color: white;
display: flex;
margin: 0px auto;
color: rgba(0, 0, 0, .87);
border: 1px solid #ddd;
width: 580px;
position: relative;
padding: 5px;
padding-left: 25px;
height: 34px;
font-size: 16px;
border-radius: 25px;
}
.search_input_area:hover {
box-shadow: 0 2px rgb(0 0 0 / 12%);
background-color: white;
border: 1px solid #dadce0;
color: #202124;
}
.search_box {
text-align: center;
display: block;
}
#google-logo {
margin-top: 200px;
width: 20%;
height: 20%;
}
<nav>
Image Search
Advanced Search
</nav>
<!--SEARCH BOX-->
<form class="search_box" action="https://www.google.com/search">
<img id="google-logo" src="google-logo.png" alt="The Google Logo">
<div>
<input name="q" type="text" class="search_input_area">
</div>
<input type="submit" value="Search Google" class="buttons">
<input type="submit" value="I'm Feeling Lucky" class="buttons">
</form>
When I hover over the search box, the background is white (as expected). However, when I type some text in the search box, the background color changes to rgb(232, 240, 254) according to the inspector. It seems as though the background color is being overwritten somewhere in the CSS.
Does anyone see why this is happening?
Thanks in advance!
Chrome changes the background of input fields if you choose a "remembered" option.
You can prevent this by customizing the :webkit-autofill pseudo class:
input:-webkit-autofill,
input:-webkit-autofill:hover,
input:-webkit-autofill:focus,
input:-webkit-autofill:active
{
-webkit-box-shadow: 0 0 0 30px white inset !important;
}
<input name="username">
In your case:
*{
font-family: arial, sans-serif;
padding: 0px;
margin: 0px;
}
body {
display: flex;
align-items: column;
flex-direction: column;
}
nav {
display: flex;
align-items: center;
justify-content: flex-end;
margin-right: 30px;
margin-top: 15px;
}
nav a {
font-size: 13px;
color: rgba(0, 0, 0, .87);
text-decoration: none;
cursor: pointer;
padding: 7px;
}
nav a:hover {
text-decoration: underline;
}
.buttons {
background-color: #f8f9fa;
border: 1px solid #f8f9fa;
border-radius: 4px;
font-size: 14px;
margin: 11px 4px;
padding: 0 16px;
line-height: 27px;
height: 36px;
min-width: 54px;
text-align: center;
cursor: pointer;
user-select: none;
display: inline-block;
margin-top: 30px;
}
.buttons:hover {
box-shadow: 0 1px rgb(0 0 0 / 10%);
background-color: #f8f9fa;
border: 1px solid #dadce0;
color: #202124;
}
.search_input_area {
background-color: white;
display: flex;
margin: 0px auto;
color: rgba(0, 0, 0, .87);
border: 1px solid #ddd;
width: 580px;
position: relative;
padding: 5px;
padding-left: 25px;
height: 34px;
font-size: 16px;
border-radius: 25px;
}
.search_input_area:hover {
box-shadow: 0 2px rgb(0 0 0 / 12%);
background-color: white;
border: 1px solid #dadce0;
color: #202124;
}
.search_box {
text-align: center;
display: block;
}
#google-logo {
margin-top: 200px;
width: 20%;
height: 20%;
}
.search_input_area:-webkit-autofill,
.search_input_area:-webkit-autofill:hover,
.search_input_area:-webkit-autofill:focus,
.search_input_area:-webkit-autofill:active
{
-webkit-box-shadow: 0 0 0 30px white inset !important;
}
<!DOCTYPE html>
<html lang="en">
<head>
<title>Google</title>
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<link rel="stylesheet" href="search.css">
</head>
<body>
<!--NAVIGATION LINKS-->
<nav>
Image Search
Advanced Search
</nav>
<!--SEARCH BOX-->
<form class="search_box" action="https://www.google.com/search">
<img id="google-logo" src="google-logo.png" alt="The Google Logo">
<div>
<input name="q" type="text" class="search_input_area">
</div>
<input type="submit" value="Search Google" class="buttons">
<input type="submit" value="I'm Feeling Lucky" class="buttons">
</form>
</body>
</html>
This question already has answers here:
How can I make a div not larger than its contents?
(43 answers)
Closed 1 year ago.
https://jsfiddle.net/cje0nuq1/
HTML
<form action="" class="form">
<div class="form-input-wrap">
<div class="form__header">Leave a review</div>
<div class="input-area">
<label>Name</label>
<input type="text" name="name">
</div>
<textarea class="text-input"></textarea>
</div>
<input type="submit" value="Publish">
</form>
CSS
:root {
--first-color: rgb(250, 250, 250);
--second-color: rgb(255, 102, 102);
--third-color: rgb(255, 74, 74);
}
.form {
display: -webkit-box;
display: -ms-flexbox;
display: flex;
-webkit-box-orient: vertical;
-webkit-box-direction: normal;
-ms-flex-direction: column;
flex-direction: column;
font-family: Arial, Helvetica, sans-serif!important;
margin: 0 auto;
width: 650px;
min-height: 200px;
background: var(--first-color);
color: #000;
padding: 5%;
border: thin solid #ccc;
}
.form__header {
margin: 0 auto;
color: var(--third-color);
font-size: 20px;
margin-bottom: 15px;
font-weight: bold;
text-align: center;
}
.form-input-wrap {
width: 60%;
}
.input-area {
display: -webkit-box;
display: -ms-flexbox;
display: flex;
-webkit-box-align: center;
-ms-flex-align: center;
align-items: center;
padding-bottom: 5px;
margin-bottom: 15px;
border-bottom: thin solid #ccc;
width: auto;
}
.input-area label {
width: 150px;
font-size: 20px;
color: var(--third-color);
}
.input-area input {
border: thin solid #ccc;
height: 22px;
}
.input-area input:focus {
outline: none!important;
}
.text-input {
resize: none;
width: 90%;
min-height: 100px;
}
.text-input:focus {
outline: none;
}
.form input[type="submit"] {
width: auto;
margin: 0 auto;
background: var(--third-color);
color: #fff;
border: none;
border-radius: 15px;
padding: 5px;
margin-top: 15px;
}
.form input[type="submit"]:hover {
background: darkred;
cursor: pointer;
}
How to make .input-area container take the exact same amount of space that its childs take?
Apply width:fit-content:
.form {
display: -webkit-box;
display: -ms-flexbox;
display: flex;
-webkit-box-orient: vertical;
-webkit-box-direction: normal;
-ms-flex-direction: column;
flex-direction: column;
font-family: Arial, Helvetica, sans-serif!important;
margin: 0 auto;
width: 650px;
min-height: 200px;
background: var(--first-color);
color: #000;
padding: 5%;
border: thin solid #ccc;
}
.form__header {
margin: 0 auto;
color: var(--third-color);
font-size: 20px;
margin-bottom: 15px;
font-weight: bold;
text-align: center;
}
.form-input-wrap {
width: 60%;
}
.input-area {
display: -webkit-box;
display: -ms-flexbox;
display: flex;
-webkit-box-align: center;
-ms-flex-align: center;
align-items: center;
padding-bottom: 5px;
margin-bottom: 15px;
border-bottom: thin solid #ccc;
width: fit-content;
}
.input-area label {
width: 150px;
font-size: 20px;
color: var(--third-color);
}
.input-area input {
border: thin solid #ccc;
height: 22px;
}
.input-area input:focus {
outline: none!important;
}
.text-input {
resize: none;
width: 90%;
min-height: 100px;
}
.text-input:focus {
outline: none;
}
.form input[type="submit"] {
width: auto;
margin: 0 auto;
background: var(--third-color);
color: #fff;
border: none;
border-radius: 15px;
padding: 5px;
margin-top: 15px;
}
.form input[type="submit"]:hover {
background: darkred;
cursor: pointer;
}
<form action="" class="form">
<div class="form-input-wrap">
<div class="form__header">Leave a review</div>
<div class="input-area">
<label>Name</label>
<input type="text" name="name">
</div>
<textarea class="text-input"></textarea>
</div>
<input type="submit" value="Publish">
</form>
to include Firefox, i would use max-contentinstead fit-content in place width:auto;that you have set for .input-area.
.form {
display: -webkit-box;
display: -ms-flexbox;
display: flex;
-webkit-box-orient: vertical;
-webkit-box-direction: normal;
-ms-flex-direction: column;
flex-direction: column;
font-family: Arial, Helvetica, sans-serif!important;
margin: 0 auto;
width: 650px;
min-height: 200px;
background: var(--first-color);
color: #000;
padding: 5%;
border: thin solid #ccc;
}
.form__header {
margin: 0 auto;
color: var(--third-color);
font-size: 20px;
margin-bottom: 15px;
font-weight: bold;
text-align: center;
}
.form-input-wrap {
width: 60%;
}
.input-area {
display: -webkit-box;
display: -ms-flexbox;
display: flex;
-webkit-box-align: center;
-ms-flex-align: center;
align-items: center;
padding-bottom: 5px;
margin-bottom: 15px;
border-bottom: thin solid #ccc;
width:max-content;
}
.input-area label {
width: 150px;
font-size: 20px;
color: var(--third-color);
}
.input-area input {
border: thin solid #ccc;
height: 22px;
}
.input-area input:focus {
outline: none!important;
}
.text-input {
resize: none;
width: 90%;
min-height: 100px;
}
.text-input:focus {
outline: none;
}
.form input[type="submit"] {
width: auto;
margin: 0 auto;
background: var(--third-color);
color: #fff;
border: none;
border-radius: 15px;
padding: 5px;
margin-top: 15px;
}
.form input[type="submit"]:hover {
background: darkred;
cursor: pointer;
}
<form action="" class="form">
<div class="form-input-wrap">
<div class="form__header">Leave a review</div>
<div class="input-area">
<label>Name</label>
<input type="text" name="name">
</div>
<textarea class="text-input"></textarea>
</div>
<input type="submit" value="Publish">
</form>
I have a form module in html and the form looks good when it loads. However, if I click on the box to insert text, the box changes its css (different shape, different color et cetera). Also, When i stop typing and click elsewhere, the box gets back normal but the text I typed is not following the placeholder css.
Also, when I click "subscribe" after I typed the text(second screenshot). It first goes to that weird third screenshot and then I have to click again to actually submit.
MY CSS
form {
text-align: center;
}
label {
font-family:Georgia;
font-size:1em;
color: #4D4D4D;
padding: 0;
}
button {
background-color: #B02E25;
border: 1px solid;
border-color: rgba(77,77,77,0.25);
border-radius: 10px;
height: 4px;
color: white;
padding: 10px 30px;
text-align: center;
text-decoration: none;
display: inline-block;
font-family:Georgia;
display: inline-flex;
align-items: center;
font-weight: lighter;
}
input {
box-shadow:0 0 5px 1px rgba(0,0,0,0.09);
margin-bottom: 20px;
border-radius: 10px;
border:0;
width:300px
}
input:focus {
padding: 10px;
font-size: 16px;
text-align: center;
font-family:Georgia;
box-shadow:0 0 5px 1px rgba(0,0,0,0.09);
}
::placeholder {
color: #aaa;
padding: 10px;
font-size: 16px;
text-align: center;
font-family:Georgia;
}
input:focus::placeholder {
color: transparent;
}
MY HTML
</head>
<body>
<div class="" style="position: relative; margin-top: 15em;">
<div class="col-12" style=" display: flex; justify-content: center; align-items: center;">
</div>
<div class="" style="display: flex;justify-content:center; align-items: center;">
<form method="post" novalidate>
<input type="hidden" name="csrfmiddlewaretoken" value="Xz4wZIixFDVotjFZqBZ6nIeT0jwX3QW7G9vOpjwPubdC6QI21KlAIisj5eYz48cb">
<tr><th></th><td><input type="email" name="email" class="" placeholder="Email you want to spam" maxlength="100" required id="id_email"></td></tr>
<br>
<button type="submit">subscribe</button>
</form>
</div>
</div>
</body>
fixed doing this
form {
text-align: center;
}
label {
font-family:Georgia;
font-size:1em;
color: #4D4D4D;
padding: 0;
}
button {
background-color: #B02E25;
border: 1px solid;
border-color: rgba(77,77,77,0.25);
border-radius: 10px;
color: white;
padding: 10px 30px;
text-align: center;
text-decoration: none;
display: inline-block;
font-family:Georgia;
align-items: center;
font-weight: lighter;
font-size: 16px;
}
input {
box-shadow:0 0 5px 1px rgba(0,0,0,0.09);
margin-bottom: 20px;
border-radius: 10px;
padding: 10px;
border:0;
width:300px;
font-size:16px;
}
input:focus {
/*padding: 10px; */
text-align: center;
font-family:Georgia;
box-shadow:0 0 5px 1px rgba(0,0,0,0.09);
}
::placeholder {
color: #aaa;
padding: 10px;
font-size: 16px;
text-align: center;
font-family:Georgia;
}
input:focus::placeholder {
color: transparent;
}
I have a sign out button in my navigation menu, but it is not staying properly inline, it's slightly off, here is my code.
HTML:
<nav class="col-sm-3" style:"height:20vh;!important">
Account
Chat
Video Chat
<form action="../Universals/signout.php" id="navigation_form">
<button>Sign Out</button>
</form>
</nav>
CSS for the Links:
#navigation a {
white-space: nowrap!important;
display: flex;
justify-content: flex-end;
margin: 25px 20px 15px;
min-width: 140px;
padding: 1px!important;
font-size: 15px;
font-weight: bold;
color: black!important;
text-decoration: none;
border: none;
background-color: transparent;
background-repeat: no-repeat;
cursor: pointer!important;
outline: none;
overflow: hidden;
text-align: right!important;
align-items: right!important;
}
CSS for the Form:
#navigation_form {
white-space: nowrap!important;
display: inline;
justify-content: flex-end;
margin: 25px 20px 15px;
min-width: 140px;
padding: 1px!important;
font-size: 15px;
font-weight: bold;
color: white!important;
text-decoration: none;
border: none;
background-color: transparent;
background-repeat: no-repeat;
cursor: pointer!important;
outline: none;
overflow: hidden;
text-align: center!important;
align-items: center!important;
}
---------------------------------------------------------------------------
---------------------------------------------------------------------------
This should work:
form {
display: inline-block;
}