Showhide CSS not working on Wordpress - html

I've got this piece of CSS/HTML code that works good on jsfiddle and when I do a test.html on my browser but when I try to use it on a wordpress page (style in style.css and html on the page) just does not work.
I checked all the possibilities I could, there is no overwriting from the style, no browser problem... little help?
This is the test site:
http://manuscript.bugs3.com/
https://jsfiddle.net/1zeatcxp/
input#show, input#hide {
display:none;
}
div#paragraph {
display:none;
}
input#show:checked ~ div#paragraph {
display:block;
}
input#hide:checked ~ div#paragraph {
display:none;
}
.showthis {
float: left;
background-color:#9b2f00;
border-style: solid black 1px;
color: #f2e07b;
padding: 5px;
box-shadow: 3px 3px 3px black;
text-align: center;
width: 80%;
}
.hidethis {
float: right;
background-color:#9b2f00;
border-style: solid black 1px;
color: #f2e07b;
padding: 5px;
box-shadow: 3px 3px 3px black;
<label for="show">
<div class="showthis">
<span>[Show]</span></div></label><input type=radio id="show" name="group"><label for="hide"><div class="hidethis"><span>[Hide]</span></div></label>
<input type=radio id="hide" name="group">
<div id="paragraph">Content</span>

It looks like your HTML is being mangled by the wordpress editor, this is what I see on your page:
<div class="showthis">[Show]</div>
<p><input id="show" name="group" type="radio"><label for="hide"><br>
</label></p>
<div class="hidethis">[Hide]</div>
<p><label for="hide"></label><br>
<input id="hide" name="group" type="radio"></p>
<div id="paragraph">
<p>Content</p>
</div>
As you already discovered, remove_filter ('the_content', 'wpautop'); is the correct way to deal with this problem. You must make sure to place this in the functions.php file of your theme.
Edit:
Try it with the following HTML:
<label for="show"><span class="showthis">[Show]</span></label>
<input type=radio id="show" name="group">
<label for="hide"><span class="hidethis">[Hide]</span></label>
<input type=radio id="hide" name="group">
<div id="paragraph">Content</div>
You should not be nesting block-level divs inside of label elements. It is not valid HTML, see https://stackoverflow.com/a/18609649/2126792.

Related

How to create different css styles to different input radio boxes?

I have a form with several input radio type:
<form class="search" action="{{ url_for('np.bkg') }}" method="post">
<input type="text" name="query" style="max-width:700px" placeholder="Search over bkg..." id="query" value="{{query}}" autocomplete="on" required>
<button type="submit"><i class="fa fa-search"></i></button>
<div>
<input type="radio" name="searchType" id="kmatch" value="kmatch" checked="checked"> match </input>
<input type="radio" name="searchType" id="kextraction" value="kextraction"> extract </input>
</div>
</form>
In my css I have this:
form.search input[type=text] {
padding: 10px;
font-size: 17px;
border: 1px solid grey;
float: left;
width: 100%;
background: #f1f1f1;
border-radius: 15px;
}
Now, my question, how to create a different css style for the 2nd input radio type? The current 'input' css element will apply to both radio boxes.
EDIT: I think my css only applies to the first input type='text' tag. So the question is the same, how to make different css styles for 2 different input radio tags?
Try this (for more attractive and user-friendly layout):
<style>
.radio-label{
border: 1px solid #abc;
border-radius: 4px;
padding: 7px 7px 5px 3px;
cursor: pointer;
box-shadow: 0 0 10px #abc;
}
.radio-label.radio-1{
background-color: #ddf;
}
.radio-label.radio-2{
background-color: #eed;
}
</style>
<label class="radio-label radio-1" for="radio-1"><input type="radio" name="radio-btn" id="radio-1" >Radio 1</label>
<label class="radio-label radio-2" for="radio-2"><input type="radio" name="radio-btn" id="radio-2" >Radio 2</label>
EDIT: You can also play with radio inputs with:
.radio-label input{
width: 20px;
height: 20px;
position: relative;
top: 4px;
}
for different styles, you can either give the two elements two different classes and define style for those classes :
.radio-input1{
width:20px;
height:20px;
}
.radio-input2{
width:10px;
height:10px;
}
or you can give the two inputs, two different ids and repeat the above code:
#radio1{
width:20px;
height:20px;
}
#radio2{
width:10px;
height:10px;
}
for classes:
<input class="radio-input1">
for id :
<input id="radio1">

How to modify the styles of the values of the radio buttons in CSS?

I am completely new to programming and I am trying to make a simple survey page to start. I am only using CSS and HTML. I have made radio buttons but I am not sure how to 'select' them in CSS.
Below is my HTML code. I would like to style the questions that are in element <p> but I want to do them all differently. I know I can select p {'how I want font, etc.. styled here} and then style in CSS but I want them all slightly different colors. When I try .survey-question-1 p {'how I want font styled here'} nothing happens.
I really don't know what selectors to use to call the elements I want to change.
<div class='survey-name'>
First name: <input type='text' id= 'firstname' name='FirstName'><br>
Last name: <input type='text' name='LastName'><br>
</div>
<div class='survey-question-1'>
<p>Are you a Front-End or Back-End Developer?</p>
<input type='radio' name='developer' value='Front-End'> Front-End<br>
<input type='radio' name='developer' value='Back-End'> Back-End<br>
</div>
<div class='survey-question-2'>
<p>How many years of experience do you have?</p>
<input type='radio' name='years' value='less than 1'> less than 1<br>
<input type='radio' name='years' value='1-2'> 1-2<br>
<input type='radio' name='years' value='2-3'> 2-3<br>
<input type='radio' name='years' value='3-4'> 3-4<br>
<input type='radio' name='years' value='4-5'> 4-5<br>
<input type='radio' name='years' vale='more than 5'> more than 5<br>
</div>
A good practice is to label your radio buttons. (See MDN page for labels). So I assume you will change your markup accordingly.
Secondly you probably want to use the attribute selector to target the radio buttons. You can also use the :checked pseudo selector for styling the checked radio button.
And thirdly, to style radio buttons you might need to apply appearance: none.
.survey-question-1 input[type="radio"] {
appearance: none;
-moz-appearance: none;
-webkit-appearance: none;
background: pink;
border: 0.5ex solid pink;
border-radius: 100%;
width: 1em;
height: 1em;
}
.survey-question-1 input[type="radio"]:checked {
background: rebeccapurple;
}
<form>
<fieldset class='survey-question-1'>
<legend>
Are you a Front-End or Back-End Developer?
</legend>
<label>
<input type='radio' name='developer' value='Front-End'>
Front-End
</label>
<label>
<input type='radio' name='developer' value='Back-End'>
Back-End
</label>
</fieldset>
</form>
Bear in mind, this is a hideous design, but it will show you how to change the color/styling of every single component on your page.
Let me know if there is specific styling you were after or if something is unclear.
/* Style Survey Name section */
.survey-name {
color: green;
}
.survey-name input {
border: 1px solid green;
}
/* Style Survey Q1 section */
.survey-question-1,
.survey-question-1 p {
color: red;
}
.survey-question-1 input[type='radio']:after {
width: 15px;
height: 15px;
border-radius: 15px;
top: -2px;
left: -1px;
position: relative;
background-color: white;
content: '';
display: inline-block;
border: 2px solid gray;
}
.survey-question-1 input[type='radio']:checked:after {
width: 15px;
height: 15px;
border-radius: 15px;
top: -2px;
left: -1px;
position: relative;
background-color: red;
content: '';
display: inline-block;
visibility: visible;
border: 2px solid gray;
}
/* Style Survey Q2 section */
.survey-question-2,
.survey-question-2 p {
color: blue;
}
.survey-question-2 input[type='radio']:after {
width: 15px;
height: 15px;
border-radius: 15px;
top: -2px;
left: -1px;
position: relative;
background-color: white;
content: '';
display: inline-block;
border: 2px solid gray;
}
.survey-question-2 input[type='radio']:checked:after {
width: 15px;
height: 15px;
border-radius: 15px;
top: -2px;
left: -1px;
position: relative;
background-color: blue;
content: '';
display: inline-block;
visibility: visible;
border: 2px solid gray;
}
<div class='survey-name'>
First name: <input type='text' id='firstname' name='FirstName' /><br />
Last name: <input type='text' name='LastName' /><br />
</div>
<div class='survey-question-1'>
<p>Are you a Front-End or Back-End Developer?</p>
<input type='radio' name='developer' value='Front-End' /> Front-End<br>
<input type='radio' name='developer' value='Back-End' /> Back-End<br>
</div>
<div class='survey-question-2'>
<p>How many years of experience do you have?</p>
<input type='radio' name='years' value='less than 1' /> less than 1<br>
<input type='radio' name='years' value='1-2' /> 1-2<br>
<input type='radio' name='years' value='2-3' /> 2-3<br>
<input type='radio' name='years' value='3-4' /> 3-4<br>
<input type='radio' name='years' value='4-5' /> 4-5<br>
<input type='radio' name='years' vale='more than 5'> more than 5<br>
</div>
See also JSFiddle
Resources I used:
Radio Button Styling
:After CSS

Create text-area dotted on each line

I would like to make a contactform like this one: http://line25.com/wp-content/uploads/2012/letter-form/20.jpg (a multi-line textarea where each line has a dotted border-bottom, like a notebook. So not just the bottom border of the field)
The name and e-mail fields I already have:
#contactform input[type="text"]{
border: none;
border-bottom: dashed 2px #c9c9c9;
width: 200px;
}
but I seem unable to fix the message part...? I thought it would be a textarea with some styling but I don't seem to get the right effect... Is it even possible to style each line separatly?
Thank you!
With textarea use an dot image as background.
#contactform textarea {
background: url("dot-bg.png");
}
only add this
<input type="text" class="field-name" value=""/>
<textarea class="field-message"></textarea>
input[type="text"].field-name{
border-bottom: dashed 2px #c9c9c9;
width: 300px;
}
textarea.field-message{
border-bottom: dashed 2px #c9c9c9;
width: 300px;
resize:none;
}
No use images, the size of the webpage is more.
You can add a div instead of textarea and add multiple input tags in it. Working JSFiddle https://jsfiddle.net/n16vrqda/ try this
label{
margin-right: 22px;
}
.message{
float: left;
margin-top: 10px;
margin-right: 10px;
}
input[type="text"].field-name{
border:none;
border-bottom: dotted 2px #c9c9c9;
width: 300px;
margin:10px;
}
.field-message{
float:left;
}
<label>Name : </label>
<input type="text" class="field-name" value=""/><br>
<label>Email : </label>
<input type="text" class="field-name" value=""/><br>
<div>
<label class="message">Message : </label>
<div class="field-message">
<input type="text" class="field-name" value=""/><br>
<input type="text" class="field-name" value=""/><br>
<input type="text" class="field-name" value=""/><br>
</div>
</div>

Dynamic color change in ASP.NET Radio Button using CSS

I managed to reach the desired results using a standard HTML Form but when I started modifying the layout to use ASP.NET web controls instead... I can't seem to get the same effect to happen. The original CSS/HTML I used is as follows:
<html>
<head>
<style>
div.sqgrp1 {
position: absolute;
top: 123px;
height: 40px;
width: 40px;
border-style: solid;
border-width: 1px;
border-color: #178e62;
background-color: #6ec3a1;
padding-left:0px;
padding-top:0px;
padding-bottom:0px;
padding-right:0px;
border-radius:10px;
}
input[type="radio"] {
display: none;
}
input[type="radio"] + label span {
display: inline-block;
width: 40px;
height: 40px;
margin: 0px 0px 0px 0px;
vertical-align: middle;
cursor: pointer;
border-radius:10px;
background-color:red;
background-size:0px;
background:black;
opacity:0;
}
input[type="radio"]:checked + label span {
opacity: 0.6;
}
</style>
</head>
<body><form id="phq9" name="phq9" action="process.aspx" method="post" runat="server">
<div class="sqgrp1" style="left: 660px;">
<input type="radio"id="Q1A1" value="1" name="Q1" /><label for="Q1A1" ><span></span></label>
</div>
<div class="sqgrp1" style="left: 730px;">
<input type="radio"id="Q1A2" value="2" name="Q1" /><label for="Q1A2"><span></span></label>
</div>
<div class="sqgrp1" style="left: 800px;">
<input type="radio"id="Q1A3" value="3" name="Q1" /><label for="Q1A3"><span></span></label>
</div>
<div class="sqgrp1" style="left: 870px;">
<input type="radio"id="Q1A4" value="4" name="Q1" /><label for="Q1A4"><span></span></label>
</div>
</form>
</body>
</html>
I tried several ways to make the same effect happen with ASP.NET controls but none of them worked so I reverted back to the regular HTML controls.
Figured out the issue I was having. Setting up all the controls as asp was fine but making the label asp:label was resulting in errors with the CSS. By leaving the label tag as normal html the CSS works exactly the same, even with the radio buttons as <asp:radiobutton runat="server">.

Why can't I tab into CSS3 checkboxes?

I've been following tutorial on styling checkboxes using only CSS3 and here's what I came up with:
DEMO:
http://cssdeck.com/labs/jaoe0azx
Checkboxes are styled just fine - but when I tab through form controls -> checkbox is being skipped. Any advice why?
HTML:
<form role="form" id="login_form" data-mode="login">
<div class="form-group">
<label for="ue">Username or email:</label>
<input type="email" class="form-control input-lg" name="ue" id="ue" placeholder="" />
</div>
<div class="form-group">
<label for="password">Password:</label>
<input type="password" class="form-control input-lg" name="password" id="password" placeholder="" />
</div>
<div>
<input id="rememberme" type="checkbox" name="rememberme" value="1" class="checkbox_1" tabindex="0" />
<label for="rememberme" class="checkbox_1" tabindex="0">remember me</label>
</div>
<div id="auth_area_login_button">
<button class = "btn btn-lg btn-primary">
Login
</button>
</div>
</form>
CSS:
#import url('//netdna.bootstrapcdn.com/bootstrap/3.0.3/css/bootstrap.min.css');
#login_form{padding:20px;}
label.checkbox_1 {
display: inline-block;
cursor: pointer;
position: relative;
padding-left: 25px;
margin: 0px;
}
label.checkbox_1:before {
content: "";
display: inline-block;
width: 16px;
height: 16px;
margin-right: 10px;
position: absolute;
left: 0;
bottom: 1px;
background-color: #fff;
border: 1px solid #ccc;
border-radius: 0px;
}
label.checkbox_1:hover:before{border-color:#66afe9;}
input[type=checkbox].checkbox_1 {
display: none;
}
input[type=checkbox].checkbox_1:checked + label.checkbox_1:before {
content: "\2713";
font-size: 15px;
color: #A0A0A0;
text-align: center;
line-height: 15px;
}
EDIT 1:
seems to work in firefox, but not in chrome...
Input must be accessible to receive focus. It works in chrome/chromium if you add following lines.
input[type=checkbox].checkbox_1 {
opacity: 0;
}
input[type=checkbox].checkbox_1:focus + label.checkbox_1:before {
border: 1px solid #66afe9;
}
Since the real checkbox is hide with display:none you can't focus it but you can also don't hide the element just make it be under the :before of the label:
input[type=checkbox].checkbox_1 {
position: absolute;
width: 16px;
height: 16px;
margin: 0;
border: 1px solid transparent;
margin-top: 3px;
}
Check this http://cssdeck.com/labs/pl4ljry7
Tested in Chrome
Because, it is not a checkbox.
Look at the css:
input[type=checkbox].checkbox_1 {
display: none;
}
The checkbox is actually hidden. So, you will not be able to focus it. The stylized square and checkmark shown are through the :before pseudo element on label. Pseudo-elements can't be focused. Nor can the labels.
I know this is an old question, but I came up with a Jquery solution when the CSS solution didn't work for me, and thought others might find this helpful. I wrapped the input in a div with the desired tabindex value and the class "checkbox-add-tabindex". Then, using Jquery, I transferred the tabindex from the div to the input.
HTML:
<div class="checkbox-add-tabindex" tabindex="10">
<input id="rememberme" type="checkbox" name="rememberme" value="1" class="checkbox_1" tabindex="0" />
<label for="rememberme" class="checkbox_1" tabindex="0">remember me</label>
</div>
Jquery:
$(".checkbox-add-tabindex").focus(
function () {
var tabval = $(this).prop("tabindex");
$(this).removeAttr("tabindex");
$(this).children(":first").attr("tabindex", tabval);
$(this).children(":first").focus();
})