Case convert (text-transform) on click using HTML and CSS - html

I am trying to create a text area in WordPress where I can type/paste any text and by clicking on the button, all of them should be UPPER/lower CASE (using HTML and CSS).
Here is the code I have added to the top of the content:
HTML area;
<div id="form">
<textarea placeholder="Type or paste text here"></textarea>
<div class="wp-block-columns">
<div class="wp-block-column"><button type="button" class="uppercase">UPPER CASE</button></div>
<div class="wp-block-column"><button type="button" class="lowercase">lower case</button></div>
</div>
</div>
Here is the CSS that I used in theme custom CSS setting:
#form textarea {
height: 25vh;
min-height: 7.25em;
max-height: 67vh;
resize: vertical;
}
#form .wp-block-columns {
margin: 0;
}
#form .wp-block-column {
margin-top: 0.5rem;
margin-bottom: 0.5rem;
}
#form button {
width: 100%;
}
.wp-block-column.uppercase {
text-transform: uppercase;
}
.wp-block-column.lowercase {
text-transform: lowercase;
}
The text area is fine, buttons are good but the text is not converting. I am new and tried many things all day so now I need expert advice. Thanks

You can easily do it using input and label HTML tags. Here's the code:
HTML:
HTML area;
<input type="radio" name="case" id="upper-case">
<input type="radio" name="case" id="lower-case">
<div id="form">
<textarea class="a" placeholder="Type or paste text here"></textarea>
<div class="wp-block-columns">
<div class="wp-block-column">
<label class="uppercase" for="upper-case">
UPPER CASE
</label>
</div>
<div class="wp-block-column">
<label class="lowercase" for="lower-case">
lower case
</label>
</div>
</div>
</div>
CSS:
#form textarea {
height: 25vh;
min-height: 7.25em;
max-height: 67vh;
resize: vertical;
}
#form .wp-block-columns {
margin: 0;
}
#form .wp-block-column {
margin-top: 0.5rem;
margin-bottom: 0.5rem;
}
#form button {
width: 100%;
}
#upper-case:checked ~ #form textarea {
text-transform: uppercase;
}
#lower-case:checked ~ #form textarea {
text-transform: lowercase;
}
input {
visibility: hidden;
}
label {
display: block;
text-align: center;
background-color: lightgrey;
padding: 5px;
border-radius: 20px;
cursor: pointer;
}

Related

How to apply a long block of css to one whole div section (login form)

I have a login form section that I have enclosed inside a div. I want this section of the page only to be styled by the css shown below. However, when I add the css in the style, it isn't applied. I think it is down to syntax. I am trying to add styles within styles.
<div class="login-form">
<form action="/action_page.php" method="post">
<div class="imgcontainer">
<img src="img_avatar2.png" alt="Avatar" class="avatar">
</div>
<div class="container">
<label for="uname"><b>Username</b></label>
<input type="text" placeholder="Enter Username" name="uname" required>
<label for="psw"><b>Password</b></label>
<input type="password" placeholder="Enter Password" name="psw" required>
<button type="submit">Login</button>
<label>
<input type="checkbox" checked="checked" name="remember"> Remember me
</label>
</div>
The existing css is below (note there is bootstrap enabled and the bottom part of the css is relevant to another part of the site -the intro part and div)
It's in the first part
.login-form {
body {font-family: Arial, Helvetica, sans-serif;}
that I've tried to refer to the div class for the form I want styled.
<style>
.login-form {
body {font-family: Arial, Helvetica, sans-serif;}
form {border: 3px solid #f1f1f1;}
input[type=text], input[type=password] {
width: 100%;
padding: 12px 20px;
margin: 8px 0;
display: inline-block;
border: 1px solid #ccc;
box-sizing: border-box;
}
button {
background-color: #4CAF50;
color: white;
padding: 14px 20px;
margin: 8px 0;
border: none;
cursor: pointer;
width: 100%;
}
button:hover {
opacity: 0.8;
}
.cancelbtn {
width: auto;
padding: 10px 18px;
background-color: #f44336;
}
.imgcontainer {
text-align: center;
margin: 24px 0 12px 0;
}
img.avatar {
width: 40%;
border-radius: 50%;
}
.container {
padding: 16px;
}
span.psw {
float: right;
padding-top: 16px;
}
}
.intro-text {
width: 1000px;
padding:15px;
margin:40;
}
Can someone point out the error with some best practices on applying several styles to one div. I have already applied styles correctly, as can be seen with the
intro-text {
width: 1000px;
padding:15px;
margin:40;
}
which is correctly applied to:
<div class="intro-text">
<h1 class="display-5">Login</h1>
<p>Welcome back</p>
</div>
I cannot figure out how to apply the more complex styles to just the login-form div class and have tried several things.
The css you have is not valid. You cannot nest css blocks like that. I would recommend take a look at the css selectors.
Let's say you want to target a button inside the div with class login-form. Instead of doing this:
.login-form{
button{
//this doesn't work
}
}
You should do this:
.login-form button{
//css here
}
.login-form {
font-family: Arial, Helvetica, sans-serif;
}
.login-form form {border: 3px solid #f1f1f1;}
.login-form input[type=text], .login-form input[type=password] {
width: 100%;
padding: 12px 20px;
margin: 8px 0;
display: inline-block;
border: 1px solid #ccc;
box-sizing: border-box;
}
.login-form button {
background-color: #4CAF50;
color: white;
padding: 14px 20px;
margin: 8px 0;
border: none;
cursor: pointer;
width: 100%;
}
.login-form button:hover {
opacity: 0.8;
}
.login-form .cancelbtn {
width: auto;
padding: 10px 18px;
background-color: #f44336;
}
.login-form .imgcontainer {
text-align: center;
margin: 24px 0 12px 0;
}
.login-form img.avatar {
width: 40%;
border-radius: 50%;
}
.login-form .container {
padding: 16px;
}
.login-form span.psw {
float: right;
padding-top: 16px;
}
.intro-text {
width: 1000px;
padding:15px;
margin:40;
}
Here is a snippet with the proper css:
<link rel="stylesheet" href="style.css">
<div class="login-form">
<form action="/action_page.php" method="post">
<div class="imgcontainer">
<img src="img_avatar2.png" alt="Avatar" class="avatar">
</div>
<div class="container">
<label for="uname"><b>Username</b></label>
<input type="text" placeholder="Enter Username" name="uname" required>
<label for="psw"><b>Password</b></label>
<input type="password" placeholder="Enter Password" name="psw" required>
<button type="submit">Login</button>
<label>
<input type="checkbox" checked="checked" name="remember"> Remember me
</label>
</div>
</form>
</div>
Syntax use is not correct , nesting in css shoud be in you case like
.login-form form {
// css code here
}
so apply selector and space and other selector for nesting properties
so every css rules in your code to be applyed only to this page , should be preceded with parent selector (.login-form) in your case .
but for the body , it cant be applied by this way ,
to apply some font for only this page , you could use by example :
adding class to body in this page then apply css as :
<body class="login-page">
// rest of html
</body>
and css should be :
body.login-page {font-family: Arial, Helvetica, sans-serif;}
Also I forget to mention that the syntax you used before, is like the scss syntax, but it should be precompiled to browser understandable css formt , thus you project should as modern web project to precompile scss to css .

Margin of Paragraph Tag goes outside of Div

Extra margin from a paragraph tag is forcing a button downwards. I am trying to understand why.
Here's one answer I tried looking to find an answer from : is it a bug? margins of P element go outside the containig div, however the answer quotes "collapsing margins" but I don't understand why that would be a correct answer, as margins don't seem to be collapsing in this case but expanding.
I understand the problem can be fixed by giving the paragraph tag a margin of 0, but I want to know why the margin is bleeding, and (if is due to margin collapse), a more verbose explanation from the other answer..
.body {
height: 100%;
}
.error {
color: red;
}
#chatbox {
width: 500px;
height: 500px;
background-color: #93ff95;
border: 1px solid black;
}
#loginContainer {
text-align: right;
height: 50px;
line-height: 50px;
}
#loginContainer input {
height: 25px;
font-size: 16px;
}
input#login {
text-transform: uppercase;
background: none;
color: blue;
border: none;
}
#loginForm {
margin: auto;
display: block;
}
#messagesArea {
height: 350px;
background-color: white;
padding: 5px;
}
#messageBox {
height: 100px;
padding: 1px 1px;
}
#messageForm {
display: none;
}
#messageBoxBlocked {
width: 100%;
height: 100%;
border: none;
border-radius: 5px;
padding: 0;
margin: none;
}
<div id="chatbox">
<div id="loginContainer">
<form id='loginForm'>
<span class="error">Invalid Username</span>
<input type="text" name="username" placeholder="Enter a username"/>
<input id="login" type="submit" name="login" value="Login"/>
</form>
</div>
<div id="messagesArea">
<p>Admin: Hey Everyone!</p>
</div>
<div id="messageBox">
<button id="messageBoxBlocked">Log in to enter chat</button>
<form id="messageForm">
<textarea name="messageBox" placeholder="Enter a message"></textarea>
<input type="submit" name="Send"/>
</form>
</div>
</div>
There isn't a problem with the margin of the p-tag.
Your #messagesArea height is too high. You can fix it by decreasing it to height: 338px; as shown in the example below:
.body {
height: 100%;
}
.error {
color: red;
}
#chatbox {
width: 500px;
height: 500px;
background-color: #93ff95;
border: 1px solid black;
}
#loginContainer {
text-align: right;
height: 50px;
line-height: 50px;
}
#loginContainer input {
height: 25px;
font-size: 16px;
}
input#login {
text-transform: uppercase;
background: none;
color: blue;
border: none;
}
#loginForm {
margin: auto;
display: block;
}
#messagesArea {
height: 338px;
background-color: white;
padding: 5px;
}
#messageBox {
height: 100px;
padding: 1px 1px;
}
#messageForm {
display: none;
}
#messageBoxBlocked {
width: 100%;
height: 100%;
border: none;
border-radius: 5px;
padding: 0;
margin: none;
}
<div id="chatbox">
<div id="loginContainer">
<form id='loginForm'>
<span class="error">Invalid Username</span>
<input type="text" name="username" placeholder="Enter a username"/>
<input id="login" type="submit" name="login" value="Login"/>
</form>
</div>
<div id="messagesArea">
<p>Admin: Hey Everyone!</p>
</div>
<div id="messageBox">
<button id="messageBoxBlocked">Log in to enter chat</button>
<form id="messageForm">
<textarea name="messageBox" placeholder="Enter a message"></textarea>
<input type="submit" name="Send"/>
</form>
</div>
</div>

How do I align a checkbox to the left of label text in NetSuite's online customer form?

I saw lot of answers with regards to styling a checkbox so that you get a checkbox followed by its label. But was not able to find an answer for my issue.
I am trying to render the same behavior in NetSuite's online customer form which interestingly put the the checkbox first and then the label at the bottom.
Can anyone help in this?
The snippet of the code is as follows:
<HTML>
<Head>
<title>OnlineLeadForm</title>
<base href="https://forms.netsuite.com/">
<script type=text/javascript>
function kVoid() { return; }
function kenshoo_conv(type,value,orderId,promoCode,valueCurrency) {
var hostProtocol = (("https:" == document.location.protocol) ? "https" : "http");
var url = hostProtocol+"://5039.xg4ken.com/media/redir.php?track=1&id=4a9f7db0-00a0-4b70-91b3-dddf4a74da2e&type="+ type + "&val=" + value + "&orderId=" + orderId + "&valueCurrency=" + valueCurrency + "&promo-Code=" + promoCode + "&ref=" + document.referrer;
var a = new Image(1,1);
a.src = url;
a.onload = function() { kVoid(); }
}
</script>
<style type="text/css">
iframe {
border:none;
}
body {
background: #ffffff;
font-family: Arial, Helvetica, Sans;
font-size: 13px;
padding: 0;
}
form {
margin-top: 50px;
min-height: 400px;
width: 420px;
max-width: 420px;
border:none;
}
input, select, textarea {
font-family: 'Lucida Grande';
font-size: 12px !important;
border: #DED9D3 1px solid;
width: 100%;
padding: 5px 7px;
color: #685C54 !important;
}
textarea {
height: 100px;
resize: none;
}
#gtk_details {
padding: 10px;
border: 1px solid silver;
background: white;
margin: 0 0 10px 0;
}
#gtk_details p {
color: #685C54;
font-size: 10px;
line-height: 14px;
margin: 0 0 12px 0;
white-space: normal;
}
label {
display: block;
cursor: pointer;
font-family: Arial, Helvetica, Sans;
font-size: 13px;
font-weight: normal;
color: #685C54;
margin-bottom: 0.2em;
}
td.smalltextnolink {
width: 120px;
height: 40px;
padding-right: 10px;
}
td {
padding-bottom: 10px;
}
fieldset {
margin: 0;
border: 0;
padding: 0;
}
legend {
background: #B79F8C;
padding: 5px 15px;
color: #fff;
font-weight: lighter;
}
form p {
margin: 0.5em 0;
}
p.splitInput {
float: left;
width: 202px;
}
p.splitInput.margin {
margin-right: 15px;
}
p.splitInput#cityBlock {
width: 200px;
}
p.splitInput#stateBlock {
width: 75px;
}
p.splitInput#zipBlock {
width: 115px;
}
p.splitInput#OptInNewLeadsBlock {
width: 400px;
float: left;
}
p.splitInput input, p.splitInput select {
width: 100%; /* Inputs should be 100% of the parent p tag's width */
}
.container {
display: inline-block;
white-space: nowrap;
float: left;
}
.clear {
clear: both;
height: 0;
}
input#submit_btn {
width: auto;
float: left;
border: 0;
padding: 0;
margin: 0;
}
</style>
</Head>
<body>
<NLFORM>
<!-- Hidden input -->
<nlcategory>
<!-- Hidden input -->
<fieldset>
<p>
<label for="companyname">Business name <img alt="Required" src="https://forms.netsuite.com/images/chiles/pageTitle/required.png"></label>
<nlcompanyname>
</nlcompanyname></p>
<p class="splitInput margin">
<label for="firstname">First name <img alt="Required" src="https://forms.netsuite.com/images/chiles/pageTitle/required.png"></label>
<nlfirstname>
</nlfirstname></p>
<p class="splitInput">
<label for="lastname">Last name <img alt="Required" src="https://forms.netsuite.com/images/chiles/pageTitle/required.png"></label>
<nllastname>
</nllastname></p>
<div class="clear"></div>
<p class="splitInput margin">
<label for="email">Email<img alt="Required" src="https://forms.netsuite.com/images/chiles/pageTitle/required.png"></label>
<nlemail>
</nlemail></p>
<p class="splitInput">
<label for="website" value="test">Website</label>
<nlurl>
</nlurl></p>
</fieldset>
<fieldset>
<p class="splitInput margin">
<label for="phone">Phone<img alt="Required" src="https://forms.netsuite.com/images/chiles/pageTitle/required.png"></label>
<nlphone>
</nlphone></p>
<div class="clear"></div>
<p class="splitInput margin" id="cityBlock">
<label for="city">City</label>
<nlcity>
</nlcity></p>
<p class="splitInput margin" id="stateBlock">
<label for="state">State</label>
<nlstate>
</nlstate></p>
<p class="splitInput" id="zipBlock">
<label for="zipcode">Zip</label>
<nlzipcode>
</nlzipcode></p>
<div class="clear"></div>
<p class="splitInput margin">
<label for="country">Country<img alt="Required" src="https://forms.netsuite.com/images/chiles/pageTitle/required.png"></label>
<nlcountry>
</nlcountry>
</p>
<div class="clear"></div>
<div class="container">
<p>
<nlcustentity89>
</nlcustentity89>
<label for="OptInNewLeads">Be the first to hear about new arrivals, exclusive offers and more.</label>
</p>
</div>
<p class="splitInput">
<input id="submit_btn" onclick="javascript:kenshoo_conv('wholesalelead','0','0','0','USD');" alt="Submit" src="https://www.manduka.com/media/site-media/wholesale/130118_btn_sbmt_V2.jpg" type="image">
</p>
</fieldset>
</nlcategory>
</form>
</Body>
</HTML>
where custentity89 is the internal id of our custom checkbox entity field in our NetSuite account.
Attached is a screenshot of how NetSuite renders the checkbox currently in our online customer form.
I am just trying to display the checkbox on the left of its label text on the same line like a regular checkbox field.
Update 1: After changing the label to inline-block like Quiver mentioned in his comment, my form now looks as below:
Online customer form
It's hard to know what exactly the problem is without all of the code. But try change your label from display: block to display: inline-block.

Styling a file-upload button

I am creating a simple file-upload web. This is the code that i have:
<form action="" method="post" enctype="multipart/form-data">
<input type="file" id="upload-photo" name="files[]" multiple="multiple" accept="image/*"/>
<button type="submit" value="Upload!">Upload</button>
</form>
I've seen a lot questions pretty much like mine but I couldn't find a solution. Maybe I can't apply them to my code. Not sure how to use labels cause after I create one it appears as text and I am not able to style it like a button. Also a piece of space stays blank, after i change the opacity of the <input type="file" id="upload-photo" name="files[]" to 0.Any advice would be helpful.
Thanks in advance.
Check this snippet
What you need to do is to provide a label for the input field and style as it would be a button
#upload-photo {
height: 0;
width: 0;
}
#upload-photo-label {
border: 1px solid #cccccc;
padding: 5px 30px;
font-family:arial;
font-size: 13px;
}
#upload-photo-label:active{
background:#ccc;
}
<form action="" method="post" enctype="multipart/form-data">
<input type="file" id="upload-photo" name="files[]" multiple="multiple" accept="image/*"/>
<label id="upload-photo-label" for="upload-photo">Browse</label>
<button type="submit" value="Upload!">Upload</button>
</form>
you can do it like this
Html
<div class="box">
<input type="file" name="file-1[]" id="file-1" class="inputfile inputfile-1" data-multiple-caption="{count} files selected" multiple style="display: none;" />
<label for="file-1"><svg xmlns="http://www.w3.org/2000/svg" width="20" height="17" viewBox="0 0 20 17"><path d="M10 0l-5.2 4.9h3.3v5.1h3.8v-5.1h3.3l-5.2-4.9zm9.3 11.5l-3.2-2.1h-2l3.4 2.6h-3.5c-.1 0-.2.1-.2.1l-.8 2.3h-6l-.8-2.2c-.1-.1-.1-.2-.2-.2h-3.6l3.4-2.6h-2l-3.2 2.1c-.4.3-.7 1-.6 1.5l.6 3.1c.1.5.7.9 1.2.9h16.3c.6 0 1.1-.4 1.3-.9l.6-3.1c.1-.5-.2-1.2-.7-1.5z"/></svg> <span>Choose a fileā€¦</span></label>
</div>
Css
.box {
background-color: #dfc8ca;
padding: 6.25rem 1.25rem;
}
.js .inputfile {
width: 0.1px;
height: 0.1px;
opacity: 0;
overflow: hidden;
position: absolute;
z-index: -1;
}
button, input {
line-height: normal;
}
button, input, select, textarea {
font-family: inherit;
font-size: 100%;
margin: 0;
}
inputfile-1 + label {
color: #f1e5e6;
background-color: #d3394c;
}
.inputfile + label {
max-width: 80%;
font-size: 1.25rem;
font-weight: 700;
text-overflow: ellipsis;
white-space: nowrap;
cursor: pointer;
display: inline-block;
overflow: hidden;
padding: 0.625rem 1.25rem;
}
svg:not(:root) {
overflow: hidden;
}
.inputfile-1 + label {
color: #f1e5e6;
background-color: #d3394c;
}
.inputfile + label {
max-width: 80%;
font-size: 1.25rem;
font-weight: 700;
text-overflow: ellipsis;
white-space: nowrap;
cursor: pointer;
display: inline-block;
overflow: hidden;
padding: 0.625rem 1.25rem;
}
here demo link https://jsfiddle.net/7we705q1/5/

Left align form labels and space out input elements

I'm struggling to left align the labels on my form and space out the input and button element/s. Can anyone offer any advice on how I can get it done, while keeping the input elements centred?
CSS code:
.bt input {
border: 1px solid #ccc;
color: rgb(60, 60, 60);
display: block;
width: 80%;
padding: 1em;
margin: 0 auto;
}
.bt button {
width: 100%;
padding: 1.5em;
background-color: #1f1f1f;
color: #fff;
border: 0;
}
.bt button:hover {
background-color: #818181;
cursor:pointer;
}
.fbc {
text-align: center;
}
.bt .fb {
background-color: #D5D5D5;
padding: 2em;
color: #585858;
display: inline-block;
width: 50%;
}
HTML code:
<div class="bt fbc">
<div class="fb">
<label>Name (Required)
<input type="text" placeholder="Name" required autofocus>
</label>
<label>Email (Required)
<input type="text" placeholder="example#domain.com" required autofocus>
</label>
<button>SUBMIT BOOKING</button>
</div>
</div>
Jsfiddle: http://jsfiddle.net/r11qv9kh/1/
Define new styles for labels:
.bt label {
margin-bottom: 1em;
display: block;
box-sizing: border-box;
padding: 0 10%;
text-align: left;
}
and change width styles for inputs:
.bt input {
...
width: 100%;
box-sizing: border-box;
}
And in this case you don't have to modify HTML.
Demo: http://jsfiddle.net/r11qv9kh/3/light/
Your labels are inline elements, and therefore will get their text alignment from their parent element. You can give them a block display and assign their text alignment directly to get them going left.
HTML:
<label for="name">Name (Required)</label>
<input id="name" type="text" placeholder="Name" required autofocus>
CSS:
.bt label {
text-align: left;
display: block;
}
Fiddle: http://jsfiddle.net/r11qv9kh/2/
This will align your labels to the left:
Text-align: left;