I am having a bit of trouble getting a form btn to stay to the right of its associated form input. It is fine when the browser is an appropriate size, however, when the browser is reduced, this btn moves onto a line below the input rather than staying to the left. I have tried pretty much everything I can think of, but I cant stop it from moving when the window is shrunk.
Any help would be greatly appreciated.
Here is the css:
#footer-newsletter form {
display: block;
vertical-align: baseline;
}
#footer-newsletter input {
display: inline;
width: 231px;
height: 19px;
background: #202020;
border:0;
margin:0;
padding:10px;
color: #A5A5A5;
font-size: 0.85em;
font-family: 'Helvetica Neue', Arial, Helvetica, sans-serif;
-webkit-transition:background .3s ease-in-out;
-moz-transition:background .3s ease-in-out;
transition:background .3s ease-in-out;
float:left;
border-radius:0
}
#footer-newsletter button {
display: inline;
width:39px;
float:right;
height:39px;
text-indent:-9999em;
background:#202020 url(images/newsletter_arrow.png) no-repeat center center;
border:0;
margin-left:1px;
-webkit-transition:background .3s ease-in-out;
-moz-transition:background .3s ease-in-out;
transition:background .3s ease-in-out;
}
Here is the html:
<!-- BEGIN .four columns right #footer-newsletter -->
<div class="four columns right" id="footer-newsletter">
<h3>Newsletter</h3>
<p>Occasional email updates, no spam</p>
<form id="newsletter" method="post" action="http://innervisionsoftware.co.uk/wp-content/plugins/newsletter/do/subscribe.php" onsubmit="return newsletter_check(this)">
<input id="email" type="email" name="newsletter" value="Your email address" required>
<button type="submit">Submit</button>
</form>
</div>
<!-- END .four columns right #footer-newsletter -->
The container is merely a pecentage width of the larger container which is 100%.
I would usually put this code on a live site for the purposes of this question, but I cant access the usual sites from this network, so sorry about that.
Any help would be greatly appreciated.
It goes below because it's floated.
You have fixed width for your input and button so you can set a min-width to the container:
#footer-newsletter form {
min-width:295px;
}
An example http://jsfiddle.net/zX3F4/1/
Give it's parent (form#newsletter) a minimum width, when the screen size gets smaller than that size, the scrollbars will appear.
#newsletter { min-width: 300px; } /*adjust to your needs */
Related
I am trying to automatically adjust the length of the hr element to the length of the input element using CSS.
Also an animation that is executed when the focus is on the input.
I saw this solution on stackoverflow for the h2 element: How to do it with h2 element
Code:
h2{
font-size:50px;
padding:0 25%;
text-align:center;
}
h2 hr{ width:100%;height:10px;background:#000;}
<h2>
This is a very big title
<hr />
</h2>
I have tried it with the input element, but it does not work.
My Code:
hr.underline {width: 0%;}
input.input:focus hr.underline{
left:0;
width:100%;
height:2px;
background-color:#17e13f;
border:none;
margin-top:5px;
margin-left:0;
margin-bottom:0px;
}
<div>
<label for="1">Eingabe</label>
<input class="input" type="text" id="1">
<hr class="underline">
</input>
</div>
But this wont work.
Does anyone know how, or is there a better way to do that?
you are closing your input tag which is wrong input tag is self closing...
what if did:using max-content on the parent divthen giving width:100% to .underline on focus which means 100% of the parent. and transition: width 0.25s ease-in-out; for smooth animation.
div{
display:flex;
gap:5px;
}
span {
display:inline-block;
width: max-content;
}
.input:focus~.underline {
width: 100%;
}
.underline {
height: 2px;
border: none;
background-color: #17e13f;
width: 0%;
transition: width 0.25s ease-in-out;
}
<div>
<label for="1">Eingabe</label>
<span>
<input class="input" type="text" id="1">
<hr class="underline">
</span>
</div>
I am trying to get the checked checkbox to show up on our website. If you go to this page and choose a pricing plan: https://www.shiftdivorceguide.com/submit-listing/ then scroll to the bottom of the next page we have two check boxes, "I agree" and "Already have an account".
When I check them they disappear and I want them to show with a check mark in them.
HTML for I agree checkbox
<div class="checkbox form-group col-md-4 check_policy termpolicy">
<input id="policycheck" type="checkbox" name="policycheck" value="true">
<label for="policycheck">
<a target="_blank" href="https://www.shiftdivorceguide.com/terms-and-conditions/" class="help">I Agree</a>
</label>
</div>
CSS:
.checkbox input[type=checkbox] {
display: none;
}
.checkbox label:before { /*This is the css code for the existing checkbox*/
content: "";
display: inline-block;
width: 20px;
height: 20px;
top: 3px;
margin-right: 10px;
position: absolute;
left: 0;
bottom: 1px;
-webkit-transition: all 0.1s ease;
-moz-transition: all 0.1s ease;
-o-transition: all 0.1s ease;
transition: all 0.1s ease;
border-radius: 2px;
}
If I change this to to display:inline a second smaller box displays and if I check it on I Agree it jumps to the right. When I check the box the :Before instance disappears in the code along with the box on the screen
I would like the nicer larger box (not the smaller box) to remain and show as checked when someone checks it.
Can anyone point me in the right direction on how to fix this?
Thanks in advance!
According to what I understood you want to hide the first checkbox when clicked and the second one to remain. If that's what you want here is a potential solution to your problem:
HTML
<form onSubmit="yourSubmitFunction()">
<div id="policycheck">
<input type="checkbox" name="policycheck" value="PolicyCheck" onclick="hidePolicyCheckbox()"> I agree
</div>
<div id="existingAccount">
<input type="checkbox" name="alreadyHaveAnAccount" value="alreadyHaveAnAccount"> Already have an account
</div>
<input type="submit" value="Submit">
</form>
and JavaScript
function hidePolicyCheckbox() {
var policyCheckbox = document.getElementById("policycheck");
if (policyCheckbox.checked === true){
policyCheckbox.style.display = "block";
} else {
policyCheckbox.style.display = "none";
}
}
If you want your second checkbox not to move up when the first one disappear you can use policyCheckbox.style.visibility = "hidden"; instead of policyCheckbox.style.display = "none";
Is this what you are trying to achieve?
hey there I've got a problem in mobile. that's my site: dev site
today I made a dropdown menu with flags so I may switch to different languages. the problem is that the dropdown for mobile is under the hamburger nav bar...I thought about solving it with media queries (cause it happen only in mobile) help anyone?
here's the code:
<div class="navbar-header">
<button type="button" id="navbar-toggle" class="navbar-toggle" data-toggle="collapseX" data-target=".navbar-responsive-collapseX"
style="margin-top: 0px;">
<span class="icon-bar"></span>
<span class="icon-bar"></span>
<span class="icon-bar"></span>
</button>
</div>
<!--try for flag dropdown menu-->
<!--position the dropdown in it's place in the navbar-->
<div class="image-dropdown" id="image-dropdown" style=" float: right; position: relative; top: 30px;width: 45px;">
<a href="http://www.uprightpose.com/">
<input checked="checked" type="radio" id="line1" name="line-style" value="1" onclick='window.location="http://www.uprightpose.com/";' />
<!--hyperlink to the language page-->
<label for="line1"></label>
</a>
<a href="http://www.uprightpose.com/home-es-new/">
<input type="radio" id="line2" name="line-style" value="2" onclick='window.location="http://www.uprightpose.com/home-es-new/";' />
<label for="line2"></label>
</a>
</div>
<!--end of flag dropdown menu-->
and that's the CSS:
<style>
#image-dropdown {
/*style the "box" in its minimzed state*/
width:80px; height:50px; overflow:hidden;
/*animate collapsing the dropdown from open to closed state (v. fast)*/
-moz-transition: height 0.1s;
-webkit-transition: height 0.1s;
-ms-transition: height 0.1s;
-o-transition: height 0.1s;
transition: height 0.1s;
}
#image-dropdown:hover {
height:200px; /*overflow-y:scroll;*/
/*nice and smooth expand - speed this up at your preference or remove animation altogether*/
-moz-transition: height 0.5s;
-webkit-transition: height 0.5s;
-ms-transition: height 0.5s;
-o-transition: height 0.5s;
transition: height 0.5s;
}
#image-dropdown input {
/*hide the nasty default radio buttons. like, completely!*/
position:absolute;top:0;left:0;opacity:0;
}
#image-dropdown label[for="line1"] {
/*style the labels to look like dropdown options, kinda*/
display:none; margin:2px; height:46px; opacity:0.2;
/*setting correct backgrounds - add additional rules with selectors based on "for" attribute, something like label[for=line2]{background-image:...}*/
background:url("https://lipis.github.io/flag-icon-css/flags/4x3/gb.svg");
background-size: 40px;
background-repeat: no-repeat;
border-radius: 7px;
width: 40px;
height: 30px;
}
#image-dropdown label[for="line2"] {
/*style the labels to look like dropdown options, kinda*/
display:none; margin:2px; height:46px; opacity:0.7;
/*setting correct backgrounds - add additional rules with selectors based on "for" attribute*/
background:url("https://lipis.github.io/flag-icon-css/flags/4x3/es.svg");
background-size: 40px;
background-repeat: no-repeat;
border-radius: 7px;
width: 40px;
height: 30px;
}
#image-dropdown:hover label{
/*this is how labels render in the "expanded" state. we want to see only the selected radio button in the collapsed menu, and all of them when expanded*/
display:block;
}
#image-dropdown label:hover {
opacity:0.5;
}
#image-dropdown input:checked + label {
/*tricky! labels immediately following a checked radio button (with our markup they are semantically related) should be fully opaque regardless of hover, and they should always be visible (i.e. even in the collapsed menu*/
opacity:1 !important; display:block;
}
/*pfft, nothing as cool here, just the value trace*/
#trace {margin:0 0 20px;}
</style>
I would try "Sticking" them one next to each other with float:right on both of the elements - putting both of them under the same container. Note the changes I've done (its written with inlined style because I can only modify it by DEV tools).
<div class="image-dropdown" id="image-dropdown" style="float: right; position: relative; top: 30px; width: 45px;">
<a href="http://www.uprightpose.com/">
<input checked="checked" type="radio" id="line1" name="line-style" value="1" onclick="window.location="http://www.uprightpose.com/";">
<!--hyperlink to the language page-->
<label for="line1" style=""></label>
</a>
<a href="http://www.uprightpose.com/home-es-new/">
<input type="radio" id="line2" name="line-style" value="2" onclick="window.location="http://www.uprightpose.com/home-es-new/";">
<label for="line2"></label>
</a>
</div>
<div class="navbar-header" style="display: inline-block;float: right;">
<button type="button" id="navbar-toggle" class="navbar-toggle" data-toggle="collapseX" data-target=".navbar-responsive-collapseX" style="margin-top: 0px; position: relative;top: 30px;">
<span class="icon-bar"></span>
<span class="icon-bar"></span>
<span class="icon-bar"></span>
</button>
</div>
I think the result is what you need (both of them aligned one next to each other) for screens with short width:
This question already has answers here:
How do I vertically align text in a div?
(34 answers)
Closed 6 years ago.
What the hell am I doing wrong haha.
I don't want to set the div's height because it should be set to auto depending on the image next to it. Am I using the tag wrong or something?
See my attached code.
Any help is greatly appreciated.
*{margin:0;padding:0;box-sizing:border-box;}
.hugme{margin:0 auto;max-width:947px;}
[class*=bit-]{float:left;padding:5px;}
#font-face {
font-family: 'Market Deco';
font-style: normal;
font-weight: normal;
src: local('Market Deco'), url('http://www.adambwhitten.com/obsw/Market_Deco.woff') format('woff');
}
/* Grids */
.box{background:#ed1b2e;font-family: 'Open Sans', sans-serif;font-size:14px;font-weight:700;text-align:center;padding:10px 0;}
.box-2{background:#00aabe;}
.bit-1{width:100%;}
.bit-2{width:50%;}
.bit-2-2{width:50%;}
.bit-3{width:33.33333%;}
.bit-4{width:25%;}
.bit-5{width:20%;}
.bit-6{width:16.66667%;}
.bit-7{width:14.28571%;}
.bit-8{width:12.5%;}
.bit-9{width:11.11111%;}
.bit-10{width:10%;}
.bit-11{width:9.09091%;}
.bit-12{width:8.33333%;}
.bit-25{width:25%;}
.bit-40{width:40%;}
.bit-60{width:60%;}
.bit-75{width:75%;}
.bit-35{width:35%;}
.bit-65{width:65%;}
.holdsmaller{max-width: 960px; margin: 0 auto;}
/* Buttons / Video Styles */
.holdbutton1 {
z-index:899;
margin: 10px;
}
.holdbutton2 {
z-index:899;
margin: 10px;
}
.holdbutton3 {
z-index:899;
margin: 10px;
}
.button-wrapper{
position:absolute;
width:100%;
height: 100%;
display:flex;
justify-content: center;
align-items: center;
flex-wrap: wrap;
}
.btnFall {
-webkit-border-radius: 5;
-moz-border-radius: 5;
border-radius: 5px;
color: #ffffff;
width:200px;
font-size: 14px;
background: #772539;
padding: 10px 20px 10px 20px;
text-decoration: none;}
.btnFall:hover {
background: #959356;
text-decoration: none;
}
#media only screen and (max-width: 756px){
.button-wrapper{flex-direction: column;}
}
#cf {position:relative; width:100%; margin:0 auto;}
#cf img {position:absolute; left:0; width:100%; height:auto; -webkit-transition: opacity 1s ease-in-out; -moz-transition: opacity 1s ease-in-out; -o-transition: opacity 1s ease-in-out; transition: opacity 1s ease-in-out;}
#cf img.top:hover{opacity:0;}
.showmobile{display:none;}
/* Responsive Goodness */
/* Defaults above are set Desktop resolution or higher */
/* Laptop */
#media (min-width:50em) and (max-width:68.75em){
.bit-7,.bit-35,.bit-65{width:100%;}
.bit-10,.bit-12,.bit-4,.bit-8{width:50%;}
}
/* Tablet */
#media (min-width:30em) and (max-width:50em){
.bit-10,.bit-12,.bit-4,.bit-6,.bit-8{width:50%;}
.bit-1,.bit-11,.bit-3,.bit-5,.bit-7,.bit-9{width:100%;}
img.product {margin-top:43px;}
img.product2 {margin-top:56px;}
}
/* Mobile */
#media (max-width:30em){
.bit-4{width:50%;}
.bit-1,.bit-10,.bit-11,.bit-12,.bit-2,.bit-3,.bit-5,.bit-6,.bit-7,.bit-8,.bit-9{width:100%;}
#cf, img.product, img.product2, img.hidemobile, .button-wrapper {display:none;}
.showmobile {display:block;}
}
<div class="hugme">
<div class="bit-2">
<div class="inner" style="vertical-align:middle;">
<font style="font-family:'Market Deco'; font-size:50px; color:#772539;">BOOT UP</font><br>
<font style="font-size:18px; color:#000;">Short, tall, over the knee, or with plush touches.<br>This fall, take your pick.</font>
<div class="btnFall" style="text-align:center;">SHOP NOW ></div>
</div>
</div>
<div class="bit-2">
<div id="cf">
<a href="http://www.google.com/">
<img class="bottom" src="http://i.imgur.com/J3DOMlR.jpg" width="100%"/> <!-- hover -->
<img class="top" src="http://i.imgur.com/dMmmOz9.jpg" width="100%"/> <!-- static -->
</a>
</div>
</div>
</div>
Thanks guys and gals!
According to MDN, vertical-align is a property used for inline elements. I don't think it would work on a div.
I want to set a button which allow the user to reset the contact form, is there any method to do it?
here is my coding for text field
<div style="float:left;width:600px;"><!--textfield-->
<div style="float:left;">
<div style="float:left;width:90px;padding-top:5px">
NAME
</div>
<div style="float:left;padding-top:4px">
:
<input type="text" class="textfield"/>
</div>
</div>
<div style="float:left;padding-top:8px;">
<div style="float:left;width:90px;padding-top:5px">
EMAIL ADDRESS
</div>
<div style="float:left;padding-top:2px">
:
<input type="text" class="textfield"/>
</div>
</div>
<div style="float:left;padding-top:8px;">
<div style="float:left;width:90px;padding-top:5px">
CONTACT NUMBER
</div>
<div style="float:left;padding-top:2px">
:
<input type="text" class="textfield"/>
</div>
</div>
<div style="width:120p;float:left;padding-top:8px;">
<div style="float:left;width:90px;padding-top:5px">
MESSAGE
</div>
<div style="float:left;padding-top:2px">
:
</div>
<div style="float:left;margin-left:3px;padding-top:2px;">
<textarea cols="48" rows="6" class="textfield"></textarea>
</div>
</div>
</div><!--textfield-->
</div><!--end leave your personal details-->
<div style="clear:both"></div>
<div>
<div id="buttonreset"><!--buttonreset-->
<img src="img/buttonreset1.png" width="54" height="24" alt="reset" />
</div><!--end.buttonreset-->
<div id="buttonsend"><!--buttonsend-->
<img src="img/buttonsend1.png" width="54" height="24" alt="send" />
</div><!--end.buttonsend-->
</div>
Css
.textfield {
font-family: CenturyGothic;
font-size: 12px;
color: #231F20;
resize: none;
text-align: left;
}
textarea {
border: thin solid #221F1F;
border-radius: 5px;
width: 430px;
height: 160px;
opacity: 0.8;
}
input {
border: thin solid #221F1F;
border-radius: 4px;
width: 430px;
height: 21px;
opacity: 0.7;
}
#buttonreset {
margin-top: 5px;
background-image: url(../img/buttonreset.png);
background-repeat: no-repeat;
height: 24px;
width: 54px;
margin-top: 10px;
margin-left: 410px;
float:left;
}
#buttonreset img {
-webkit-transition: opacity .5s ease-in-out;
-moz-transition: opacity .5s ease-in-out;
-o-transition: opacity .5s ease-in-out;
transition: opacity .5s ease-in-out;
opacity:0;
}
#buttonreset img:hover {
opacity:1;
cursor:pointer;
-webkit-animation-duration: 1s;
-webkit-animation-timing-function: linear;
Chrome, and Safari */
}
I haven't add any coding to my button, what code suitable for my button?
this is my fiddle:
http://jsfiddle.net/K5CJ4/
<input type='reset'>
is the easiest method.
[Edit]
Since you're trying to reset the form using an image, the easiest way is to use the reset() method in Javascript. (No need for a library like jQuery). To accomplish this, I simply added a bit of javascript to your <a> tag in your form, as well as wrapped the entire example in <form></form> tags, giving it an id of contactForm .
DEMO
use jQuery way to solve it. like this :
$("#buttonreset").click(function() { // div's id
$("#txtField1").val("");
$("#txtField2").val("");
});
Try to use :
<button type="reset" id="btnreset" value="Reset">Reset</button>
The button is a reset button (resets the form-data to its initial values)
#btnreset {
background-image: url("http://www.ricksdailytips.com/wp-content/uploads/2013/11/reset-button.gif");
border: 0 none;
height: 204px;
width: 200px;
}
If you want to automate this, you could set it such that the page refreshes the entire page after a given number of seconds. use the meta tag:
<meta http-equiv="refresh" content="(enter number of seconds before refresh);url=thispage.html" />