<div id='mdnew'>
<div class=' gblue mdtitle'>NEW TAG</div>
<input id='inpnew' type='text' autocomplete='off' maxlength=25 placeholder='NEW TAG'>
<div class='gblue leftcancel'>CANCEL</div>
<div class='gblue rightok' id='newok'>OK</div>
<div class='clear'></div>
</div>
when input has focus (i.e. pointer is inside) and mouse is over cancel button - input loses its left margin !
complete code is here
Wrap your input with div and it will work.
* {
margin:0;
padding:0;
box-sizing:border-box;
-moz-box-sizing:border-box;
-webkit-box-sizing:border-box;
}
#mdnew {
position:fixed;
z-index:2;
width:300px;
left:calc(50% - 150px);
top:63px;
background: red;
border-radius:5px;
overflow:hidden;
}
#inpnew {
display:block;
width:calc(100% - 28px);
margin:14px auto;
line-height:21px;
outline:none;
border:1px solid #999;
border-radius:5px;
padding:0 7px;
}
.leftcancel {
float:left;
width:50%;
line-height:23px;
cursor:pointer;
text-align:center;
}
.rightok {
float:right;
width:50%;
line-height:23px;
cursor:pointer;
text-align:center;
}
.leftcancel:hover, .rightok:hover {
opacity:0.8;
}
.gblue {
background: -webkit-linear-gradient(to top, #003b61, #0099cc);
background: linear-gradient(to top, #003b61, #0099cc);
color:white;
letter-spacing:0.5px;
}
.mdtitle {
line-height:23px;
text-align:center;
letter-spacing:0.5px;
}
<div id="mdnew">
<div class=" gblue mdtitle">NEW TAG</div>
<div>
<input id="inpnew" type="text" autocomplete="off" maxlength="25" placeholder="NEW TAG" >
</div>
<div class="gblue leftcancel">CANCEL</div>
<div class="gblue rightok" id="newok">OK</div>
<div class="clear"></div>
</div>
Here is the Updated Fiddle..
Its because opacity of .leftcancel,rightok on hover, its effecting to the sibling
remove that part and test
.leftcancel:hover, .rightok:hover{
//opacity:0.8;
}
fiddle
Update :
To make it work with opacity, add position and z-index to .leftcancel and .rightok
The opacity you're setting on .leftcancel and .rightok is creating a new stacking context, and stacking contexts affect z-indexes. Since you didn't specify z-indexes manually, they're being auto assigned, and .leftcancel and .rightok has a higher value than #inpnew because it comes later in the markup.
Reference : W3C Color Module
If an element with opacity less than 1 is not positioned, implementations must paint the layer it creates, within its parent stacking context, at the same stacking order that would be used if it were a positioned element with ‘z-index: 0’ and ‘opacity: 1’.
*{
margin:0;
padding:0;
box-sizing:border-box;
-moz-box-sizing:border-box;
-webkit-box-sizing:border-box;
}
#mdnew{
position:fixed;
z-index:2;
width:300px;
left:calc(50% - 150px);
top:63px;
background: red;
border-radius:5px;
overflow:hidden;
}
#inpnew{
display:block;
width:calc(100% - 28px);
margin:14px auto;
line-height:21px;
outline:none;
border:1px solid #999;
border-radius:5px;
padding:0 7px;
}
.leftcancel{
position:relative;
z-index:5;
float:left;
width:50%;
line-height:23px;
cursor:pointer;
text-align:center;
}
.rightok{
position:relative;
z-index:5;
float:right;
width:50%;
line-height:23px;
cursor:pointer;
text-align:center;
}
.leftcancel:hover, .rightok:hover{
opacity:0.8;
}
.gblue{
background: -webkit-linear-gradient(to top, #003b61, #0099cc);
background: linear-gradient(to top, #003b61, #0099cc);
color:white;
letter-spacing:0.5px;
}
.mdtitle{
line-height:23px;
text-align:center;
letter-spacing:0.5px;
}
<div id='mdnew'>
<div class=' gblue mdtitle'>NEW TAG</div>
<input id='inpnew' type='text' autocomplete='off' maxlength=25 placeholder='NEW TAG'>
<div class='gblue leftcancel'>CANCEL</div>
<div class='gblue rightok' id='newok'>OK</div>
<div class='clear'></div>
</div>
Updated fiddle is : https://jsfiddle.net/5qperdzb/16/
If you're calculating input's width as 100% - 28px then it's safe to just use 14px for margin-left and margin-right:
#inpnew {
margin: 14px;
}
Related
[i want to do like this]
[1]: https://i.stack.imgur.com/OOSKk.png
I have created a div(div B) in body that has 100% width and it has another div (div A) which has two components in it.the Div A is not able to get width of only two elements its getting 100% width.
This is my code
<div id="con"> <div id="srbt"> <input id="srch" type="text" placeholder="Paste Youtube link" name="search"> <button id="btn">Download</button></div> </div>
* {
box-sizing: border-box;
}
#con {
display:block;
background: #502c6c;
height:125px;
width:100%;
padding:30px;
}
#srbt {
width:100%;
background: #ffffff;
height:65px;
border-radius:5px;
position:relative;
}
#srch {
display:block;
width:100%;
border:none;
height:65px;
border-radius:5px;
padding:0 20% 0 5%;
line-height:65px;
color:#6c7592;
font-size:20px;
}
#btn {
background:#ff5916;
border:none;
border-radius:5px;
height:59px;
width:20%;
position:absolute;
top:3px;
right:3px;
z-index:10;
color:#ffffff;
font-size:24px;
}
<div id="con">
<div id="srbt">
<input id="srch" type="text" placeholder="Paste Youtube link" name="search">
<button id="btn">Start</button>
</div>
</div>
I have this problem, I can't seem to figure out how do I make this red DIV not past through the div on the right side, I want to make it stay between the right and the left div menu.
Website Screenshot
HTML Code:
<body>
<div class="navigationBar_default">
<div class="facetubeLogo_default"></div>
<div class="facetubeText_container_default"><center><strong class="facetubeText_default"></strong></center></div>
</div>
<div class="content_default">
<div class="leftMenu_onProfile">
<button class="leftMenu_buttonOnProfile"><img class="leftMenu_buttonImage" src="images/myProfileButton_onLeftMenu_onProfile.png" /><br>MY PROFILE</button>
<button class="leftMenu_buttonOnProfile"><img class="leftMenu_buttonImage" src="images/optionsButton_onLeftMenu_onProfile.png" /><br>GENERAL</button>
<button class="leftMenu_buttonOnProfile"><img class="leftMenu_buttonImage" src="images/generalButton_onLeftMenu_onProfile.png" /><br>OPTIONS</button>
<button class="leftMenu_buttonOnProfile"><img class="leftMenu_buttonImage" src="images/supportUsButton_onLeftMenu_onProfile.png" /><br>SUPPORT US</button>
<button class="leftMenu_buttonOnProfile"><img class="leftMenu_buttonImage" src="images/logOutButton_onLeftMenu_onProfile.png" /><br>LOG OUT</button>
</div>
<!-- there must be some stuff here, otherwise leftMenu_onProfile will glitch out. -->
<div class="contentCenter_onProfile">
AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAaaaaaaaaaaaaaaAAAAAAAAAAAAAAAAAA
</div>
<!-- there must be some stuff here, otherwise leftMenu_onProfile will glitch out. -->
<div class="rightMenu_onProfile">user1<br>user2<br>user3<br>user4<br>user5</div>
</div>
CSS Code:
.navigationBar_default {
background-color:#202020;
width:100%;
height:32px;
margin-left:-8px;
margin-right:-8px;
border:0;
top:0;
position:fixed;
}
.facetubeLogo_default {
background-image:url("../images/facetube_icon_30x30_png.png");
width:30px;
height:30px;
margin-top:1px;
margin-left:1px;
float:left;
}
.facetubeText_container_default {
margin-top:6px;
}
.content_default {
width:100%;
height:100%;
margin-top:32px;
margin-left:-8px;
margin-right:-8px;
margin-bottom:-8px;
}
.leftMenu_onProfile {
background-color:#0d0d0d;
margin-top:0px;
margin-left:-8px;
width:240px;
float:left;
}
.leftMenu_buttonOnProfile {
background-color:#0d0d0d;
border:0;
border-bottom:1px solid #ffffff;
width:240px;
height:48px;
color:#ffffff;
}
.leftMenu_buttonImage {
float:left;
margin-top:-2px;
margin-right:-6px;
}
.contentCenter_onProfile {
background-color:red;
padding:2px; /* padding is originally removed */
margin:0px;
top:0px;
}
.rightMenu_onProfile {
background-color:#0d0d0d;
margin-top:-20px;
margin-right:-16px;
width:300px;
color:#ffffff;
float:right;
}
I have feeling it has to do something with content_default and the width:100% but I don't know. I tried everything and I couldn't figure it out.
:/
Try this:
.contentCenter_onProfile {
background-color:red;
padding:2px; /* padding is originally removed */
margin:0 300px;
top:0px;
width: 50%; /* SET THIS */
white-space: pre-wrap;
word-break: break-all;
}
By setting the width, you can ensure the div does not overlap the right hand side div.
Setting float: left or float: right causes the elements to overlap.
Currently my parent div is showing up as a dimensionless div (0 by 0 px). I am trying to have a flexible parent div thats size is not explicitly mentioned but rather adaps to the size of its content. Here is what I have so far thats producing a 0px by 0px parent. Hope someone can give me a solution.
HTML:
<div class="thumbnailDeal">
<div class="thumbnailImage">
<div class="thumbnailDescription">
<span class="thumbnailTitle">3 Maki Orders</span>
<div class="thumbnailPrices"><span class="thumbnailOriginal">$25</span> $<span class="thumbnailActual">15</span></div>
<br>
<span class="thumbnailRestaurant">New Generation Sushi</span><br>
<span class="thumbnailLocation">11 St Joseph st.</span>
</div>
</div>
</div>
<div class="thumbnailDeal">
<div class="thumbnailImage">
<div class="thumbnailDescription">
<span class="thumbnailTitle">3 Maki Orders</span>
<div class="thumbnailPrices"><span class="thumbnailOriginal">$25</span> $<span class="thumbnailActual">15</span></div>
<br>
<span class="thumbnailRestaurant">New Generation Sushi</span><br>
<span class="thumbnailLocation">11 St Joseph st.</span>
</div>
</div>
</div>
CSS:
.thumbnailDeal{
display: inline-block;
margin:1%;
}
.thumbnailImage{
width:360px;
height:315px;
background-size: cover;
background-image: url(../assets/5.jpeg);
background-position: center center;
background-repeat: no-repeat;
position:absolute;
}
.thumbnailDescription{
height:28%;
width:100%;
background: rgba(0, 0, 0, 0.75);
position:absolute;
bottom:0;
padding:10px;
}
.thumbnailTitle{
color:white;
font-size:17px;
}
.thumbnailRestaurant{
color:#FD8B2B;
font-family: "Helvetica Neue",Helvetica,Arial,sans-serif;
font-size:14px;
}
.thumbnailLocation{
color:#9E9E97;
font-family: "Helvetica Neue",Helvetica,Arial,sans-serif;
font-size:14px;
position:absolute;
left:0px;
bottom:0px;
padding-left:10px;
}
.thumbnailPrices{
font-size:14px;
color:white;
position:absolute;
right:0px;
bottom:-13px;
box-sizing: border-box;
}
.thumbnailOriginal{
text-decoration: line-through;
color:#9E9E97
}
.thumbnailActual{
font-size:50px;
color:white;
position:relative;
right:10px;
}
When you use position: absolute elements get out of the flow and the parent won't have height/width from his childs anymore.
You have to find another way to position your elements if you want to have a proper height/width to the parent :)
I am working for this company that has hired me to turn a new home page design of theirs into html and css. In the design they gave me there is a search box in the header that they would like to be same as the one on their current webpage (http://shop.manorfinewares.com/intro.html). I am unsure how to navigate their current page's source code in order to successfully transfer the search box to the new page I am designing for them. Here is the header code that I have so far...
CSS:
#header{
position:absolute;
width:100%;
top:0;
height:107px;
min-width:600px;
border-bottom: 1px dotted #86beca;
}
#headerContainer{
position:relative;
width:100%;
margin:0 auto;
top:0;
height:107px;
max-width:1280px;
min-width:600px;
border-bottom: 1px dotted #86beca;
}
.headerUtilityContainer{
float:left;
padding-top:4px;
margin-left:8%;
width:22%;
height:103px;
}
.headerUtilityContainer img{
float:left;
margin-top:2px;
width:40%;
height:9px;
}
.headerLogoContainer{
float:left;
margin:0px;
width:40%;
height:107px;
}
.headerLogoContainer img {
display:block;
margin-top:30px;
margin-left:auto;
margin-right:auto;
width: 55%;
max-width:250px;
height: 57%;
}
.searchContainer{
float:left;
text-align:right;
font-size:70%;
padding-top:4px;
margin-right:8%;
width:22%;
height:103px;
}
.headerBorderDiv{
float:left;
width:100%;
margin:0 auto;
padding:0px;
height:2px;
border-bottom: 1px dotted #86beca;
HTML:
<div id="header">
<div id="headerContainer">
<div class="headerUtilityContainer">
<img src="images/manorSocialButtons.png" />
</div>
<div class="headerLogoContainer">
<img src="images/homePageLogo.png"/>
</div>
<div class="searchContainer">
LOGIN / REGISTER CART (0)
</div>
</div>
</div>
ANY advice will be very helpful as I am not sure where to start. I have never worked with XLS search bars in the past
It's still unclear as to what exactly you want, a right floated search bar with clear icon on input? I have created this fiddle for you, it replicates the behaviour of site you mentioned.
http://jsfiddle.net/DP22Y/
HTML
<div id="container">
<div id="utility">Utility</div><!--
--><div id="logo">Logo</div><!--
--><div id="search">LOGIN / REGISTER | CART (0)
<span class="clearable">
<input class="data_field" type="text" name="search" placeholder="Search..."/>
<span class="icon_clear">x</span>
</span>
</div>
</div>
CSS
#container{
margin:0 auto;
height:100px;
width:80%;
}
#utility, #logo, #search{
box-sizing: border-box;
color:#000;
height:100%;
float:left;
}
#utility{
background:#f1f1f1;
width:33.3%;
padding:10px;
}
#logo{
background:#e0e0e0;
width:33.3%;
padding:10px;
}
#search{
background:#e9e9e9;
width:33.3%;
padding:10px;
text-align:right
}
#search > #data_field{
margin:10px 0 10px;
padding:5px;
width:100px;
float:right;
}
span.icon_clear{
position:absolute;
right:10px;
top:0px;
display:none;
cursor:pointer;
font: bold 1em sans-serif;
color:#38468F;
}
span.icon_clear:hover{
color:#f52;
}
.clearable{
position:relative;
}
.data_field{
padding-right:17px; /* add space for the 'x' icon*/
width:100px;
}
jQuery
$(document).on('propertychange keyup input paste', 'input.data_field', function(){
var io = $(this).val().length ? 1 : 0 ;
$(this).next('.icon_clear').stop().fadeTo(300,io);
}).on('click', '.icon_clear', function() {
$(this).delay(300).fadeTo(300,0).prev('input').val('');
});
As far as the functionality is concerned, that is a different question altogether. That depends on what language you are using, do you want to make the results appear on page reload or without that using ajax, whats the db scheme etc. But the basic search would be something like this
Wrap search field with a form
Set an action and method for the form
Action will be the page the search results will be shown on
I have this CSS
.menuPopup div {
width: 100%;
padding: 5px;
}
.menuClose {
width:10px;
height:10px;
padding:0px;
position:absolute;
top:0px;
right:0px;
cursor:pointer;
}
Which should apply to this HTML:
<div class="menuPopup">
<div >A</div>
<div >B</div>
<div >C</div>
<div class="menuClose">X</div>
</div>
When applied, the .menuPopup div declaration allways overrides .menuClose.
How can I change the order? ie. make the width of "X" 10px instead of 100% ?
It's because you have more selectors in the top declaration.
if you do this it should overwrite:
.menuPopup div.menuClose {
width:10px;
height:10px;
padding:0px;
position:absolute;
top:0px;
right:0px;
cursor:pointer;
}
See this article for an explanation on how css cascade priorities are handled:
http://eriestuff.blogspot.com/2007/11/css-cascade-what-defenition-takes.html
You can try using !important for the rule you want to be enforced. For example:
.menuClose {
width:10px !important;
height:10px !important;
etc...
}