CSS: Transparent pointer like the one on the App Store - html

Maybe I'm stupid atm, but I can't figure out how to do this:
http://s24.postimg.org/k9fl1y2s5/arrow.png
As you can see, the pointer/arrow inside the nav-element is transparent, but shows the content instead of it's parent, the nav-element.
This is my HTML:
<nav>
...
<div id="pointer></div> <!-- this is the arrow -->
</nav>
<div id="content">...</div>
How can I achieve that? Ugh, hope you understand what I mean... :)

Ok it took some doing but I think I have a start for you:
http://jsfiddle.net/uLDzA/2/
The main problem here is that you can't just set the ARROW to transparent as the menu div will have some sort of solid color that won't let the transparent bleed through to the main background.
I solved this by busting up the menu item into a top and bottom section. The top has text and the bottom is constructed so that we "emulate" a triangle in the middle section and give it a transparent background.
Basically build the arrow into the menu item itself by piecing it together like a CSS puzzle.
<div class="con">
<div class="item">
<div class="item_top">
top
</div>
<div class="item_btm">
<div class="item_btm_lft"> </div>
<div class="item_btm_ptr"> </div>
<div class="item_btm_rgt"> </div>
</div>
</div>
</div>
.con {
width:100px;
height:40px;
padding:20px;
background:url('http://placekitten.com/g/100/100');
}
.item {
width:100px;
background:transparent;
}
.item_top {
background:orange;
text-align:center;
color:#fff
}
.item_btm {
width:100%;
overflow:hidden;
}
.item_btm_lft {
width:40px;
float:left;
background:orange;
border-bottom:2px solid orange;
}
.item_btm_ptr {
width: 0px;
height: 0px;
float:left;
border-style: solid;
border-width: 0 10px 20px 10px;
border-color: transparent orange transparent orange;
}
.item_btm_rgt {
width:40px;
float:left;
background:orange;
border-bottom:2px solid orange;
}

Well, not sure if i got you right but:
I am pretty sure that the pointer/arrow is a seperate img file that is loaded and shown in cases like: mouse-over, active (e.g).
That means, that you creat a new .png File make the background transparent and draw it as you want. All areas where you didn t draw on are transparent.
Let's make it a little easier to understand:
Your navigation is not active nor is your mouse hovering over it. Then you should see the standard loaded img (without the pointer/arrow).
--> we hover our mouse over it or click it:
Your navigation is active now and the new image (e.g. .png file) is shown instead of the old one. This image is drawn with some areas untouched so they are transparent.

You are looking at a modern application of CSS3 techniques as demonstrated by:
http://nicolasgallagher.com/pure-css-speech-bubbles/demo/
In your example, the border colors have been made semi-transparent using rgba to specify the color.
However, the reference will not tell you how to build exactly what your screen shot is showing. It will only explain how to create the triangle motif.

Related

How to Apply border to all the elements [on hover] of facebook's page without disrupting the entire page's look and feel

Before flagging this as already asked, pls read the whole scenario. Thanks
SHORT VERSION :
Just to clearly state what i am trying to achieve, here's the page https://www.facebook.com/MercedesBenzPolska/ and I want to add border to the target element (on which i am hovering), whether it be <div> or <img> or <p>, without the shaking
DETAILED VERSION
Webpage in question: Any of Facebook's page.
Requirement: Moving a cursor over an element should add border to the target element [only on hover therefore temporary border not permanent]. Permanent border will be added ONLY if I click on that element. [Simply, if I hover over an element it will be highlighted with, say, pink border and only when i click on it, a green border would be added]
Initial problem: adding border on elements on hover would make the whole page's structure shaky, since I am constantly adding and removing the border. For that what I did was add a transparent 1 px border to all the elements of the page, and on hover just change the color of the border from transparent to pink; thus no shaky.
Present problem: The above solution was working for all the pages till I encountered Facebook's page. It turns out adding the initial 1 px border totally disrupts the structure i.e. the look and feel of the page. DIVs move from somewhere to somewhere else.
How do I now solve my original problem? Is there a way of, maybe like, applying a negative margin or border, so that adding the extra 1 px border does not dirupt the page's structure? I don't know I am just suggesting. Pls help
[SCREENSHOTS]
1. this is when the page loads [without applying the border]
2. Now when I hover over the div containing image ie adding 1 px border on hover, the divs move here and there
css I am using
* { border: 1px solid transparent !important;} //when page loads
.hover-selected{ border: 1px solid #e42a78 !important;} //on hover border
.option-selected:hover { border: 3px solid #529c56 !important;cursor: default;} //when option is selected
The images and the css both reflect towards the same problem, the default 1px transparent border disrupts the page's css and If I don't do that, the on hover border application becomes shaky and the page's css anyway gets disrupt
box-shadow: 0px 0px 0px 1px #000;
Use box shadow instead border. Box-shadow don't take up space.
div {
width:300px;
height:300px;
background: red;
}
div:hover {
box-shadow: 0px 0px 0px 1px #000 inset;
}
<div> Test </div>
outline is perfect for this. It works in a very similar way to border but does not effect layout at all.
div:hover {
outline: 1px solid orange;
}
<div>
Lorem ipsum sit amet.
</div>
<div>
<img src="https://placehold.it/200x100">
</div>
<div>
Lorem ipsum sit amet.
</div>
you can use box-sizing property in css. Try below code with and without box-sizing property
<div class="item">
</div>
.item {
box-sizing: border-box;
height: 50px;
width:50px;
background:red;
}
.item:hover{
border:1px solid black;
}
I would start from something like this and move from there:
*:hover:last-child:before {
display:block;
content:"";
position:absolute;
top:0;
bottom:0;
left:0;
right:0;
border:2px solid red !important;
}
Using a pseudo-element instead of putting a border on the actual object might not create as many issues with the initial layout. Still not exactly what you asked for, but I believe it's at least a bit closer. :-)
EDIT
I believe that the only way to achieve this as good as possible would be to be less greedy when selecting elements in the CSS, and specify a list like so:
a:hover:before,
img:hover:before{
display:block !important;
content:"" !important;
position:absolute !important;
top:0 !important;
bottom:0 !important;
left:0 !important;
right:0 !important;
border:2px solid red !important;
}

Background color and background img on Hover table cell

Hello I have a table that is made from div and setting the display to table,table-row,table-cell. On these table cells (except the nth-child(1) ) I have a background image with a grey line which I set it to the entire cell exactly as shown on the screenshot below. Now this is a bit advanced css techniques for me as I am not really a web designer but rather a software engineer however I need the background color of the row to turn grey since the background of the image is white, however it does not. If I didnt explain well, my screenshot below show the desired effect. My question is only based on how I do that ON HOVER effect.
My html code sample is like this
<div class="tableName">
<div class="tableRow">
<div class="tableCell">
<span><!--random data --></span>
</div>
<div class="tableCell">
<span><!--random data --></span>
</div>
</div>
</div>
And my css code below
.trafficTable{
display:table;
border-collapse: collapse;
width:100%;
}
.trafficRow{
display:table-row;
width:100%;
}
.trafficRow:nth-child(1){
color:#FFFFFF;
}
.trafficCell{
display:table-cell;
border:1px solid #b3b3b3;
text-align:center;
vertical-align: middle;
width:13.5%;
font-size:13px;
background-image:url("/images/strike.png");
background-size:100% 100%;
background-color:#424F90;
cursor:pointer;
}
.trafficCell:nth-child(1){
width:5%;
background-image: none !important;
color:#FFFFFF;cursor:default;
}
.trafficRow:nth-child(1) .trafficCell{
background-color:#F79B2E !important;
background-image: none !important;
cursor:default;
}
.trafficRow:nth-child(1) .trafficCell:hover{
background-color:#F79B2E !important;
}
.trafficRow:nth-child(1):hover{
background-color:#F79B2E !important;
}
.trafficCell:hover{background-color:#BA0C2F !important;}
.trafficCell:nth-child(1):hover{background-color:#424F90 !important;}
.trafficRow:hover::before{
background-color:#e6e6e6 !important;
content: '';
height:100%;
width:100%;
display:block;
}
.trafficCell span{
display:inline-block;
min-height: 182px;
width:100%;
font-weight:900;
}
Please note that obviously the class names match the css names. The answer must not be done with opacity please. I have tried numerous things including the technique I found here (the only one about closest to this scenario I am facing) with the ::before pseudo selector, still did not work.
The desired effect screenshot as promised :
Desired Effect
Edit: I guess people missunderstood my question. The desired effect shown on the screenshot is shows the desired effect ON HOVER. I know that you cant hover oin table cells until CSS4 is out and parent selector is out and thats why i will do that with javascript/jquery, basically what I am asking is why the background-color gets overwritten from the background img even thoough the background of the image is white so it shouldn't have any effect???

why does All the images shake when hovered

I have created a webpage with three images with a css property which gives it a border when hovered but when i hover all the image move a little from their origional position also how to align all the images in center
JSFIDDLE DEMO HERE!
<head>
<title>Play Stone Paper scissors
</title>
<style>
img {
margin:40px;
margin-left:10px
}
img:hover{
border:dashed;
border-color:#4DFFFF;
}
div{width: 90%; margin: 0px auto;
margin-top:40px;}
</style>
</head>
<body>
<div>
<img src="rock.jpg">
<img src="paper.jpg">
<img src="scissors.jpg">
</div>
The answer is the border itself. It changes your dom's element width. Border itself doesn't have an off state of the same width, which is what you are expecting.
Rather you need to create the off state width to remove this shake.
Either an off state with the border width or some other margin/padding to compensate.
http://developer.mozilla.org/en-US/docs/Web/CSS/box_model
Similar to : How can we avoid the shake when we hover over an element and set its border?
From the linked SO question above, fixed fiddle: http://jsfiddle.net/smitkhakhkhar/tn9Kj/
Added
border:dashed;
border-color:transparent;
I made a very small change in KnowHowSolutions original idea - thanks! - and wonder what people would think about a different approach - FIDDLE.
Put the full border in, but make it tansparent, and when hovered, change the color.
Is there any downside to this?
CSS
img {
margin: 40px;
margin-left: 10px;
border: dashed;
border-color: transparent;
}
img:hover{
border-color: #4DFFFF;
}

Adding Rollover Text to a Sprite using CSS

I'm creating a site where the homepage has rollover sprites with text that appears underneath the images on rollover. The image sprite already has an active state on rollover. I want to add an additional state: live text that appears underneath the image. I've found many solutions that can create text that appears when you roll over a plain image. However, I am unable to make it work with a sprite, mainly because the sprite's image has to live in the css and many of the examples that I've seen use it in the HTML. If someone could let me know if this is even possible using CSS or if I should try it with Javascript, it would be much appreciated!
Here is the HTML for the rollover sprite:
<div id="image_1">
<div class="roll_title">
<h4>Title</h4>
</div>
</div>
CSS:
.roll_title {
margin: 170px 0 0 0;
text-align:center;
}
#image_1 {
display:block;
width:150px;
height:150px;
background-image:url(../i/patria_roll.png);
background-repeat:no-repeat;
float:left;
margin: 50px 0 0 30px;
}
#image_1:hover {
background-position-y: -150px;
}
Give an absolute position .roll_title with display: hidden; inside #image_1 and change its display property to display: block; when #image_1 is hovered.
Here's a live example:
http://jsbin.com/doyer/1/

Problem creating equal height columns in CSS

I have been using the examples here to setup a webpage that has columns with equal heights (using only HTML and CSS), and it is working relatively well. Here is the complete HTML and CSS code that I am using.
Newbie questions:
(1) As you can see, I tried to make the left column (id="column_bottom") have a white (#f5f5f5) background with black text, and the right column (id="content_bottom") with black background with white (#f5f5f5) text, but one side is always overriding the other. What can I do to make it what I want?
(2) Also, you can see in the CSS that I have defined fonts and background colors for body, but somehow that is not carrying through, what should I do?
Thanks!
P.S. I am looking for a pure HTML/CSS solution, and prefer not to use javascript.
You're close. In your code, just change your styling to the columns themselves, like so:
#content_bottom {
color: #f5f5f5;
background:#000000; /* right column background colour */
}
#column_bottom {
color: #000000;
background:#f5f5f5; /* left column background colour */
}
the code below will create two boxes side-by-side and the container will always wrap those boxes, no matter how tall they are. this should solve your issue of having columns of the same height.
html:
<div class="container">
<div class="box">blah</div>
<div class="box">blah<br/><br/>blah</div>
<div class="clear"></div>
</div>
css:
.container { position:relative; width:100px; border:1px solid red; }
.box { position:relative; float:left; width:40px; border:1px solid blue; }
.clear { clear:both }