fix div position for mobile with media queries - html

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:

Related

CSS to hover on specific classes

I would like the button to change color on hover when hovering anywhere in the nav bar (.topNav). In my current code, the change happens only when hover over the button (.top, .middle, .bottom classes). I got this to work using span, but that was changing all the spans in the .topNav class.
html...
<nav class="navbar-default"
<div class="topNav">
<div class="navbar-header">
<button type="button" class="navbar-toggle button_container collapsed"
[ngClass]="{'active': !menuCollapsed}" (click)="toggleMenu()">
<span class="top"></span>
<span class="middle"></span>
<span class="bottom"></span>
</button>
</div>
....other content
</div>
</nav>
SCSS...
.top, .middle, .bottom {
background: white;
transition: 0.25s;
}
.topNav:hover, .button_container:hover, .top:hover, .middle:hover,
.bottom:hover {
background: black;
transition: 0.25s;
}
Here you go:
.topNav{
background: red;
}
.topNav:hover>.navbar-header>button {
background: black;
transition: 0.25s;
}
<nav class="navbar-default"><!-- OOPS YOU FORGOT TO CLOSE THIS TAG -->
<div class="topNav">
<div class="navbar-header">
<button type="button" class="navbar-toggle button_container collapsed"
[ngClass]="{'active': !menuCollapsed}" (click)="toggleMenu()">
<span class="top"></span>
<span class="middle"></span>
<span class="bottom"></span>
</button>
</div>
....other content
</div>
</nav>
You forgot to close the nav tag.
.topNav:hover>.navbar-header>button means when you hover over .topNav select a specfic child element ( the button ). Then do stuff with that ( paint it black )
header a:hover{
color:#BFEFFF;
font-weight:bold;
}
Try something like this in the CSS code.
I use this on my webpage: http://www.kunalkolhe.com/
I have heard from experienced developers that using CSS for extensive projects is not a good Idea though.
FYI... I got this to work with two solutions...
1) Using the navbar-header class and span. Previously when I tried this same solution with the .button_container class (instead of navbar-header), it did not work. I still do not understand why.
Code using span...
.navbar-header span {
background: white;
transition: 0.25s;
}
.topNav:hover>.navbar-header span {
background: black;
transition: 0.25s;
}
2) Code using the three classes...
.top, .middle, .bottom {
background: white;
transition: 0.25s;
}
.topNav:hover>.navbar-header>button>.top, .topNav:hover>.navbar-header>button>.middle, .topNav:hover>.navbar-header>button>.bottom {
background: black;
transition: 0.25s;
}

Chrome/Safari and inline-block elements

So I have a few elements in an inline-block which display perfectly as they should in Firefox but for some reason in Safari and Chrome the positioning is all off
CSS:
#bb-tools {
float: right;
width: 100%;
text-align: right;
position: absolute;
z-index: -1;
}
.main-tools {
display: inline-block;
color: #000000;
font-size: 0.8em;
margin-top: 10px;
width: auto;
height: 30px;
}
.main-tools a img.icon-space { margin-right: 5px; }
.main-tools a {
color: #000000;
text-transform: uppercase;
text-decoration: none;
margin: 0 0 0 15px;
}
.main-tools a:hover {
color: #f4cdd4;
-webkit-transition: all 0.3s;
-moz-transition: all 0.3s;
transition: all 0.3s;
}
.search-box-responsive {
display: block;
float: left;
height: auto;
}
HTML:
<div id="bb-tools">
<div class="main-tools"> <a rel="nofollow" href="#"><span class="login">Log In</span></a> <span class="help">Help</span> <a class="basket" rel="nofollow" href="#"><img src="http://www.placehold.it/20x23" width="18" height="20" style="display:inline-block; border:0;" alt="" /> <span class="basket-contents"> <span class="basket-count"><sup> (100) </sup></span></span></a>
<div class="search-box-responsive">
<form class="search-responsive" role="search" method="get" action="#">
<fieldset>
<input id="headerSearch" name="q" type="text" placeholder="Search" />
<input id="headerSearch" value="" type="submit" />
</fieldset>
</form>
</div>
</div>
</div>
See the fiddle, if opened in Firefox, displays as it should:
DEMO
Can someone explain? Thanks for reading
It's happening as none of your anchors are floated so it is pushing the form down to the next line before it can get floated.
If you wrap your anchors in a div and then add float:right to that div, it should fix your problem
Example
Note sure what is causing the issue since i didn't get what you're trying to achieve with the css.
If you just want to fix the issue, you can place the .search-box-responsive before the links in DOM, if possible.
Demo (tested in safari and chrome)
sidenote: float has no effect on absolutely possible elements, as far as i know.
Add .search-box-responsive div right after #bb-tools div as in
http://jsfiddle.net/4tjJt/2/

what is the code for reset the text field form?

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" />

CSS weirdness with width transition

Made a web portfolio. Around my name there is contact data. Initial width of text is 0, when hovering the icons expand with the "transition" property. Icons on the left work fine, but those on the right have a weird transition, especially the phone.
http://jsfiddle.net/4y9eW/
<div class="contactbox left">
<a href="https://twitter.com/D4NiMG" class="contactchild" id="contacttwittertext">
<span class="contacticon-twitter"></span>
<span class="contacttext">#D4NiMG</span>
</a>
<a href="https://plus.google.com/+DaniMu%C3%B1ozGuardiola" class="contactchild" id="contactgoogleplustext">
<span class="contacticon-google-plus"></span>
<span class="contacttext">+DaniMuñozGuardiola</span>
</a>
</div>
<span id="titlespan">Dani Guardiola</span>
<div class="contactbox right">
<a href="mailto:d4nimg#gmail.com" class="contactchild" id="contactemailtext">
<span class="contacticon-email"></span>
<span class="contacttext">d4nimg#gmail.com</span>
</a>
<a href="tel:+34607017025" class="contactchild" id="contactphonetext">
<span class="contacticon-phone"></span>
<span class="contacttext">+34 607 01 70 25</span>
</a>
</div>
CSS:
.contacttext {
display: none;
white-space: nowrap;
}
.contactchild:hover .contacttext {
display: inline-block;
}
.contactchild {
position: relative;
display: inline-block;
overflow: hidden;
width: 32px;
color: white;
transition: width 0.3s;
}
#contacttwittertext:hover {
transition: width 0.3s;
width: 107px;
color: #00aced;
}
#contactgoogleplustext:hover {
transition: width 0.3s;
width: 189px;
color: #D34836;
}
#contactemailtext:hover {
transition: width 0.3s;
width: 175px;
color: #8036d3;
}
#contactphonetext:hover {
transition: width 0.3s;
width: 154px;
color: #6fd336;
}
The problem with the phone is that the text wraps. Set
.contactchild { white-space: nowrap }
The weird overlap is caused by your misuse of position: absolute. Get rid of that. Move it around with margins, the parent forcing nowrap.
The weird underscores has to do with the spaces in the HTML. See 1 vs 2. It's <a>'s underline (note the spaces).

CSS issue with form btn moving when resized

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 */