On mouse over should appear ADD button - html

if someone could help me with this, would be great! I have some images on my webpage, and I want to make a small effect, when I'm moving the mouse over the image, should appear ADD button, in the center of the image, and around the button to be a background-color with opacity effect.
I have this HTML code:
<span class="img1" style="opacity: 1;"><img class="prodimg" src="img/naturale_pi_5_large.jpg" alt="Lily Pink Bag"></span>
<span class="img2" style="opacity: 0; visibility: visible;">
<div class="buttoncont">
Add to Cart
</div>
</span>
and also this CSS:
.buttoncont{
display:block;
width:92px;
margin:0;
background:#c33a56;
-webkit-border-radius: 4px;
-moz-border-radius: 4px;
border-radius: 4px;
}
#content .productlist .product .foot .buttoncont {
right:0;
position:absolute;
bottom:0;
}
.buttoncont a,
.buttoncont input {
display:block;
color:#ffffff;
width:100%;
height:30px;
line-height:30px;
text-align:center;
font-family: Arial, sans-serif;
font-size:90%;
background:url('img.jpg');
border:0;
padding:0;
cursor:pointer;
-webkit-border-radius: 4px;
-moz-border-radius: 4px;
border-radius: 4px;
}
.buttoncont input:hover {
text-decoration:underline;
}
.miniproductlist .imagecontainer img {
vertical-align:middle;
display:inline;
max-width:100%;
outline:#ffffff 1px solid;
}
.miniproductlist .img2 {
position:absolute;
top:0;
left:0;
visibility:hidden;
width:100%;
height:81px;
}
Thanks in advance!

If you are wrapping everything in a container than you can simply accomplish this with CSS ONLY
.container button {
display: none;
}
.container:hover button {
display: inline-block;
}
Now what we are doing here is we are hiding the button, and on hovering the container div, we are showing it, alternatively you can use visibility: hidden; but that will take up space where display: none; wont

Related

How to crop not stretch an image in a slider? I've tried 'background:cover'

I've began editing a pre-made Blogger/Blogspot template (as an amateur!!), and have come across photos in posts on a featured slider that stretch to fit the slider and look terrible. Here is the original template website where I downloaded the file: Sora Templates - 'Blogging', and it looks amazing on the example. Except my photos are not set sizes, and it would take me a very long time to crop them all to the same size.
Here is where I believe the right code is located (without images as the images are found in my posts), but I cannot seem to get Background-size: cover; to work, nor 'clip'. Is there a way to automatically have them cropped?
.related-posts{
margin:0 0% 0 0%;
background:#fff;
}
#related-posts{
border-top:1px solid #CCC;
position:relative;
padding-top:.51em;
}
.related-posts img{
border:1px solid #DEDEDE;
}
h2.relatedpost{
position:absolute;
top:-15px;
padding:0 5px 0 0;
text-indent:15px;
background:#FFF;
margin-bottom:0
}
.related-content{
float:left;
}
.related-content{}
.relatedtitle{
color:#414141;
font-variant:small-caps;
font-weight:bold;
font-size:17px!important;
}
.slider{
height: 382px!important;
padding: 10px 10px 10px 10px;
border: 1px solid #6d6e71;
}
.large-category-header {
margin-left: -30px;
margin-top: 38px;
position: absolute;
width: 100%;
z-index: 99999;
}
ul.bjqs{
position:relative;
list-style:none;
padding:0;
margin:0 0px 0;
overflow:hidden;
height:385.333333px!important;
width:100%!important;
display:block!important;
}
li.bjqs-slide{
position:absolute;
display:none;
list-style:none;
height:99%!important;
width:99.5%!important;
}
ul.bjqs-controls{
list-style:none;
margin:0;
padding:0;
z-index:9999;
}
li.slider-content img{
width:100%;
}
ul.bjqs-controls.v-centered li.bjqs-prev a,ul.bjqs-controls.v-centered li.bjqs-next a{
display:none;
}
ol.bjqs-markers{
list-style:none;
padding:0;
margin:0;
width:100%;
}
ol.bjqs-markers.h-centered{
margin-top: -34px;
position: relative;
height: 15px;
padding: 7px 4px 7px 4px;
text-align: center;
width: 98%;
background: cover;
overflow: hidden;
left: 0px !important;
}
ol.bjqs-markers li{
display:inline;
}
ol.bjqs-markers li a{
display:inline-block;
}
ul.bjqs-controls.v-centered li a{
display:none;
}
ul.bjqs-controls.v-centered li a:hover{
background:#000;
color:#fff;
}
.featured-title{
position: absolute;
bottom: 35px;
width: 93.5%;
background: rgba(0, 0, 0, 0.5);
font-weight: 600;
font-size: 25px;
font-family: 'Georgia', serif;
font-weight: 300;
padding: 20px;
text-transform: capitalize;
text-align: center;
}
.featured-posts-section{
background:#f9f9f9;
border-bottom:1px solid #ddd;
padding-top:20px;
overflow:hidden;
}
.featured-title a{
color:#fff;
}
.status-msg-wrap{display:none;}
.fpimg{
width:100% !important;
height:380px;
}
ol.bjqs-markers li a{
background: #fff;
color: #fff;
margin: 5px;
height: 10px;
border-radius: 240px;
text-decoration: none;
width: 10px;
}
ol.bjqs-markers li.active-marker a,
ol.bjqs-markers li a:hover{
background:#F26F6F;
}
p.bjqs-caption{
background:rgba(255,255,255,0.5);
}
<div class='slider' id='slider'>
<div class='large-category-header'><img alt='Featured' src='http://i1329.photobucket.com/albums/w557/iSharnie/sites%20stuff%202/featured_zpsvedkkd5i.png'/></div>
<ul class='bjqs'>
<script type='text/javaScript'>
//<![CDATA[
document.write("<script src=\"/feeds/posts/default?max-results="+numposts1+"&orderby=published&alt=json-in-script&callback=showhomeposts1\"><\/script>");
//]]></script>
</ul>
</div>
I don't think the script is actually controlling the height of the slider and its images, as in your CSS being placed into your index (dynamically) somehow, shows the "fpimg" class overriding the height and width of images placed. http://pasteboard.co/1z2hCJkX.png
Technically, if you could get into that code, if its a plugin or script, and instead of using an <img> source, and in the <a> add a background image setting in that class which loads the image you want, into the itself, you can then use background-size cover.
BUT, without having first hand access to that file or theme myself, that's about as much i can do at the moment. =) I recommend reaching out for assistance and seeing if someone can alter that plugin/script to use a background img instead of placing an actual image in the slider.

Adding a clickable button to an input without "unfocusing" the input

So I build a neat little header thingy with some awesome icons.
For the user to change the input type of the search function, I'm trying to make it so that they can do so by:
(1) clicking the magnifying glass icon to open the search bar for typing (the search bar extends using :focus)
(2) once words are typed, the user then selects the magnifying glass again (which is at the end of the search bar).
(3) this extends a list of other icons signifying types of input (i.e. a music note for an audio file).
(4) once an icon is selected, it will replace the magnifying glass icon and submit. [this part I'm doing in JavaScript so not a huge deal.]
The biggest issue(s) are that the search bar won't stay focused when clicking on the icon and that I'm not even sure if I can click on the icon at all. Any and all help is appreciated.
Here's my HTML:
<html lang="en">
<head>
<meta charset="utf-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1">
<link rel="stylesheet" type="text/css" href="icomoon/style.css">
<title>outline</title>
</head>
<body>
<header class="header">
<ul class="navigation-bar">
<li class="nav-list">
<div class="nav-item" id="search">
<label class="search-label">
<input class="search-button"><span class="icon-search" id="icon-search-span-2"></span></input>
<button class="search-type"><span class="icon-search" id="icon-search-span"></span></button></label>
</div>
</li>
<li class="nav-list"><div class="nav-item" id="login"><button class="login-button"><span class="icon-user3"></span></button></div></li>
<li class="nav-list"><div class="nav-item" id="options"><button class="options-button"><span class="icon-menu2"></span></button></div></li>
</ul>
</header>
</body>
</html>
And my CSS:
html {
background-image: url("http://www.htmlhive.com/wp-content/uploads/2012/02/bluestripes.png");
}
container {
width:100%
}
body {
margin: 0 0 0 0;
margin-top: 10px;
width: 100%;
}
.header {
background-color:#0099CC;
width:100%;
height:50px;
}
.navigation-bar {
display:table;
list-style-type: none;
margin-top:0;
margin-left:auto;
margin-right:auto;
padding: 0;
width:700px;
}
.nav-item {
font-weight:bold;
color: #FFFFFF;
background-color:transparent;
display: inline;
text-align:left;
padding:4px;
text-decoration: none;
text-transform: uppercase;
}
.nav-list {
display:table-cell;
height:30px;
}
#search {
display:table-cell;
height:30px;
width:375px;
padding-right:10px;
}
#login {
display:table-cell;
height:30px;
width:175px;
}
#options {
display:table-cell;
height:30px;
width:75px;
}
#media (max-width:700px) {
.header {
height:120px;
}
.nav-list {
display:inline-block;
vertical-align: middle;
}
#search {
text-align: left;
width:645px;
padding-top:10px;
}
#login {
display:inline-block;
padding-top: 22px;
padding-bottom: 35px;
margin-top:35px;
height:0px;
width:485px;
text-align: center;
}
#options {
display:inline-block;
height:0px;
padding-top: 22px;
padding-bottom: 35px;
margin-top:35px;
width:152px;
text-align: center;
}
.options-button {
margin-top:-20px;
}
.search-button {
margin-left:60px;
margin-top:3px;
transition:all .8s;
}
.search-button:focus {
text-align: left;
padding-left:20px;
padding-right:40px;
width:465px;
}
#icon-search-span-2 ~ .search-button {
text-align: left;
padding-left:20px;
padding-right:40px;
width:465px;
}
.search-button:focus ~ .search-type {
margin-left:545px;
}
.search-button:focus ~ #icon-search-span-2 {
color:transparent;
}
.login-button {
margin-top:-20px;
margin-right:325px;
}
#icon-search-span {
padding:40px;
line-height:17px;
margin-left:0px;
margin-top:0px;
}
}
.options-button {
background-color: transparent;
border: 2px solid #FFFFFF;
border-radius:25px;
color:#FFFFFF;
font-size:20px;
padding:5px;
width:40px;
vertical-align: middle;
}
.search-button {
background-color: transparent;
border: 2px solid #FFFFFF;
border-radius:25px;
color:#FFFFFF;
font-size:20px;
margin-left:55px;
padding:5px;
width:26px;
vertical-align: middle;
transition:all .8s;
}
#media (min-width:700px) {
#search {
position:relative;
top:0px;
}
.search-button:focus {
text-align:left;
padding-left:20px;
padding-right:40px;
width:600px;
}
.search-button:focus ~ .search-type {
margin-top:-41px;
margin-left:680px;
transition:all .8s;
}
.search-button:focus ~ #icon-search-span-2 {
color:transparent;
}
#login {
position:absolute;
vertical-align: middle;
margin-left:40px;
}
#options {
position:absolute;
vertical-align: middle;
margin-left:90px;
}
.search-button:focus ~ #login {
}
}
.login-button {
background-color: transparent;
border: 2px solid #FFFFFF;
border-radius:25px;
color:#FFFFFF;
font-size:20px;
padding:5px;
width:40px;
vertical-align: middle;
}
#icon-search-span {
padding:7px;
line-height:17px;
margin-left:-5px;
margin-top:-15px;
vertical-align: middle;
}
.search-label {
position:absolute;
margin-left:5px;
}
.search-type {
position:absolute;
background-color: transparent;
border-radius:25px;
color:#FFFFFF;
font-size:20px;
margin-top:-41px;
border:2px transparent;
margin-left:-9999px;
pointer-events: none;
padding: 5px;
height:38px;
width:38px;
vertical-align: middle;
z-index: 100;
transition:all .8s;
}
#icon-search-span-2 {
position: absolute;
font-size:20px;
margin-left:-30px;
margin-top:12px;
transition:all .2s;
}
Clicking on something removes the focus from something else - by design. You can always use JavaScript to set the focus back to the input when the selection occurs.
You probably want to use a class name and control this using JavaScript instead of the :focus pseudo-class. Using jQuery for this really makes your JavaScript easier.
CSS:
.search-button.focus {
text-align:left;
padding-left:20px;
padding-right:40px;
width:600px;
}
JS:
$('.search-button').on('click', function() {
$(this).addClass('focus');
})

Button with Number and Text

I have a HTML button, I have to display it just like smart phone dialpad. like number and ABC etc.
<a href="" class="button">
1
<span>ABC</span>
</a>
everything is fine except the text is not visible in the button. How can I solve that ?
You just need to change the style of the span to wrap correctly.
add display: inline-block; to your a span selector so that it looks like this:
a span {font-size:8px;
text-transform:uppercase;
display:block;
text-align:center;
line-height:0em;
margin-top:-5px;
font-style:italic;
display: inline-block;
}
The best solution is usually the simplest. In this case, just a one line addition.
All you need to do is add a height to your button element. Here is an updated fiddle: http://jsfiddle.net/2nv7A/8/
.button {
...
height: 100px;
}
Try this:
a span {
font-size:8px;
text-transform:uppercase;
display:block;
text-align:center;
line-height:0em;
margin-top:-15px; // pulled up the text a little more
margin-bottom:10px; // pushed down the margin at the bottom
font-style:italic;
}
Fiddle around with these and you'll find the best one for you
DEMO HERE
U can use overflow property to show the text cutting off and then can manage height of your element.
.button {
position: relative;
width: 62px;
overflow: visible;
/*border: 1px solid black;*/
border: 1px solid black;
border-radius: 12px;
/*border-radius: 7px;*/
Outline: none;
margin-left:2px;
margin-bottom:7px;
border-color:#ccc;
}
If you remove your positioning, decrease your line-height and then remove your span height (which was set to 0 preventing it from appearing) then it seems to work fine. Here
.button {
width: 62px;
/*border: 1px solid black;*/
border: 1px solid black;
border-radius: 12px;
/*border-radius: 7px;*/
Outline: none;
margin-left:2px;
margin-bottom:7px;
border-color:#ccc;
}
a{
display:inline-block;
vertical-align:top;
text-align:center;
text-decoration:none;
font-weight:bold;
line-height:25px;
overflow:hidden;
font-size:12px;
}
a span {font-size:8px;
text-transform:uppercase;
display:block;
text-align:center;
font-style:italic;
}
Decresea the line-height property of .a AND increase the line-height of a. span.
You need to change the margins on your span. Use this CSS:
a span {font-size:8px;
text-transform:uppercase;
display:block;
text-align:center;
line-height:0em;
margin-top:-10px;
font-style:italic;
margin-bottom:15px;
}
It's because you set the display:block for the span tag, which should be display:inline-block;:
a span {
font-size:8px;
text-transform:uppercase;
display:inline-block; /* <---- here */
text-align:center;
line-height:0em;
margin-top:-5px;
font-style:italic;
}
Fiddle

layout problems with CSS position

hey guys i'm trying to create a navigation system similar to the one you can find on starbucks.com. Here is the link to my sample: http://dl.dropbox.com/u/73992/js_tests/test.htm I am accomplishing the effect with navigation sample on the bottom but as you can see there are positioning problems. You can find the CSS in the source code. I figured this is the best way to test it. Thank you in advance for any help I can get it.
as per the suggestion here's the css
*
{
margin:0;
padding:0;
}
#nav
{
position:relative;
margin-top:3em;
margin-left:3em;
}
#nav ul
{
list-style-type:none;
}
#nav ul li
{
position:relative;
margin-top:10px;
}
#nav ul li ul li
{
margin-top:0px;
}
#nav ul li h1
{
font-size:15px;
font-weight:bold;
text-align:center;
color:#000000;
background-color:#F7FF88;
border:solid 5px black;
width:100px;
height:30px;
border-bottom:none;
z-index:20;
}
.content
{
position:relative;
width:300px;
background-color:#F7FF88;
border:solid 5px black;
}
.content form
{
display:block;
margin:10px 10px 10px 10px;
}
.content p
{
text-align:left;
display:block;
margin:10px 10px 10px 10px;
}
.gallery
{
margin:10px 10px 10px 10px;
background-color:#ffffff;
border:solid 1px black;
}
.gallery img
{
display:inline-block;
margin:10px 5px 10px 0px;
float:left;
}
/*
This next section is identical but represents what happens w/ the absolute positioning.
*/
.content2
{
position:absolute;
width:300px;
background-color:#F7FF88;
border:solid 5px black;
top:30px;
z-index:-5;
}
.content2 form
{
display:block;
margin:10px 10px 10px 10px;
}
.content2 p
{
text-align:left;
display:block;
margin:10px 10px 10px 10px;
}
.clear
{
clear:both;
}
if this helps this is what I am trying to accomplish
Give this a try. Change the position from absolute to relative, and remove the 30px top margin. You should be able to get the same effect as the 3 examples above yours.
.content2
{
position: relative;
width:300px;
background-color:#F7FF88;
border:solid 5px black;
z-index:-5;
}
[EDIT]
First off, remove the "border-bottom:none;" so your h1 will still have bottom borders for that tabbed effect.
#nav ul li h1
{
font-size:15px;
font-weight:bold;
text-align:center;
color:#000000;
background-color:#F7FF88;
border:solid 5px black;
width:100px;
height:30px;
z-index:20;
}
Give your h1 a class, let's say "tabbed"
<li><h1 class="tabbed">Ex. 1</h1>
And probably use some negatives for your CSS.
h1.tabbed {
position:absolute;
top:-28px;
}
Give this one a try.
Put display:inline; on li
And float:left; on ul
I think it's your big problem, if I had understand well your problem.
float : left can solve your positioning problem. You have to add just two lines in your css
#nav ul li {
float: left;
margin: 0 15px;
position: relative;
}

Mimic apple.com globalsearch input field with HTML and CSS

OK, so if you check out http://www.marioplanet.com you can see that I am trying to mimic the design of apple.com for my menu bar, including my global search bar.
Now, I'm trying to mimic Apple's input field for the global search bar, as close as I possibly can, so I need some help here.
I would like the field to be centered in the middle, which I tried by using maring: auto auto; but that did not work..
I also would like to use the rounded corner technique, from Apple's site, but I'm not sure how to do that. Is that CSS3?
I also need to have a grayed out placeholder string reading Search but I think I may be able to use JS for that. If can use HTML or CSS, please let me know.
The little spotlight / magnifying glass image aligned to the left side of the input field is nice, but not necessary :)
OK, you can check out the site, but here is the code as well:
index.htm:
<div id="globalheader" class="apple">
<!--googleoff: all-->
<ul id="globalnav">
<li id="gn-home">Home</li>
<li id="gn-catalog">Shop!</li>
<li id="gn-about">About</li>
<li id="gn-contact">Contact</li>
<li id="gn-media">Media</li>
</ul>
<div id="globalsearch">
<form id="searchform">
<div>
<input type="text" size="30" value="" id="inputString" onkeyup="lookup(this.value);" />
</div>
<div id="suggestions"></div>
</form>
</div>
<!--googleon: all-->
</div>
default.css:
body {
background-color: #666666;
font-family:Verdana, Arial, Helvetica, sans-serif;
}
#header {
background-color: #DDDDDD;
width: 1130px;
margin: 0px auto;
}
#content {
width: 1130px;
margin: 0px auto;
}
#leftcol {
background-color:#EBEBEB;
width: 200px;
height: 550px;
font-size:14px;
clear: both;
float: left;
}
#detail {
background-color:#FFFFFF;
width: 730px;
height: 550px;
font-size:12px;
float: left;
}
#rightcol {
background-color:#EBEBEB;
width: 200px;
height: 550px;
font-size:14px;
float: left;
}
#footer {
background-color:#DDDDDD;
width: 1130px;
height:90px;
font-size:12px;
text-align:center;
clear: both;
margin: 0px auto;
}
h1 {
color: #FF0000;
}
h2 {
color:#FF0000;
}
a:link {
color:#FF0000;
}
a:visited {
color:#FF0000;
}
a:hover {
color:#00FF00;
}
a:active {
color:#FF0000;
}
img {
border:none;
}
#eznetseal {
text-align:center;
}
a.trayIcon {
position: relative;
top: 20px;
}
a.trayIcon:hover {
top: 7px;
}
#twittericon {
left: 0px;
}
#facebookicon {
left: 22.5px;;
}
#youtubeicon {
left: 45px;;
}
#tray {
position:relative;
}
#container {
position:relative;
margin-top: -40px;
}
#nav li
{
display: inline;
}
#features
{
vertical-align: top;
}
globalsearch.css:
/* BASIC RESET */
body, div, img, p { padding:0; margin:0; }
a img { border:0 }
/* HTML ELEMENTS */
body { font-family:"Lucida Grande","Lucida Sans Unicode",Arial,Verdana,sans-serif; }
/* COMMON CLASSES */
.break { clear:both; }
/* SEARCH FORM */
#searchform { margin:auto auto; font-size:18px; }
#searchform div { color:#eeeeee; }
#searchform div input { font-size:18px; width:120px; }
#suggestions{ position: relative; left:235px; width:320px; display:none; }
/* SEARCHRESULTS */
#searchresults { border-width:1px; border-color:#919191; border-style:solid; width:320px; background-color:#a0a0a0; font-size:10px; line-height:14px; }
#searchresults a { display:block; background-color:#e4e4e4; clear:left; height:56px; text-decoration:none; }
#searchresults a:hover { background-color:#b7b7b7; color:#ffffff; }
#searchresults a img { float:left; padding:5px 10px; }
#searchresults a span.searchheading { display:block; font-weight:bold; padding-top:5px; color:#191919; }
#searchresults a:hover span.searchheading { color:#ffffff; }
#searchresults a span { color:#555555; }
#searchresults a:hover span { color:#f1f1f1; }
#searchresults span.category { font-size:11px; margin:5px; display:block; color:#ffffff; }
#searchresults span.seperator { float:right; padding-right:15px; margin-right:5px;
background-image:url(../images/shortcuts_arrow.gif); background-repeat:no-repeat; background-position:right; }
#searchresults span.seperator a { background-color:transparent; display:block; margin:5px; height:auto; color:#ffffff; }
Thanks!
On the div containing the textbox try text-align: center; border-width: 0px; margin-top: 6px; to do the watermark try a jquery watermark plugin
For the rounded corners apple are inserting images into spans either end. I have seen the magnifying glass done this way or by setting the image as a background-image and adding padding to avoid overwriting it.
If I were you id download firebug for firefox so you can explore the markup and css yourself, it's quite easy.
Hope this helps.
I used Firebug and Web Developer extension to find following...
Apple definately use javascript ( and of course css) to make that search box look preety.
if you turn of javascript using noscript you will see a normal square text box.
you can check following javascript and css files to figure out whats going on.
http://images.apple.com/global/scripts/search_decorator.js
http://images.apple.com/global/nav/styles/nav.css
in css files take a look at following rule set
#globalsearch .search-wrapper .left
and
#globalsearch .search-wrapper .right
following are the images used to create the search box
http://images.apple.com/global/nav/images/searchfield_leftcap.png
http://images.apple.com/global/nav/images/searchfield_rightcap.png
I found following interesting things.
They have dedicated script file just to make that search box look pretty
They do not use image sprites.
I tried to smush one of the above images and was able to smush it by 15% ( it might look trivial but when you are looking at website visited by millions this can become a big number )