CSS Animated Side-button-tag - html

There is a tag trigger on the right side of each line.
Some of those tags may contain messages. Initially only an indicator icon
is shown and the message is hidden. (I draw the overflow
for demonstration, but there may be other methods) When the shown icon
is hovered, the whole tag would move to the left and showing the
message with a button.
Now here is the problem. Firstly I cannot animate the tag with scalable message length in pure CSS. Secondly since I'm using fixed height for each line, I cannot set the right property for vertical alignment for the message text.
Here is my attempt http://codepen.io/rix/pen/DaGyk.

1. To align the left edge of the message to the right edge of the row regardless of the message length: first position the message absolutely with a right: 50px (since you'd want the left icon to show), then apply a transform: translateX(100%):
.card-item .control {
position: absolute;
right: 50px;
transform: translateX(100%);
/* other styles... */
}
2. To animate the message on hover: you need to define a transition on .control, then simply transform: translateX(0) on :hover. Also, set right: 0 so that the right edge of the message is flush with the right edge of the row.
.card-item .control {
position: absolute;
right: 50px;
transform: translateX(100%);
transition: all 0.3s;
/* other styles... */
}
.card-item .control:hover {
right: 0;
transform: translateX(0);
}
3. To vertically align the message text: since you have a fixed height for the message, set the line-height of the message text to the row height which is 50px, and vertical-align: top:
.card-item .control .message {
/* remove this: margin-top: -8px; */
line-height: 50px;
vertical-align: top;
}
http://codepen.io/myajouri/full/jCBiH

In this example I have the pop-over-part under the card popping out to the right. Changing the right: -10 to 10 and changing background-position: to top left should help you out. You can play around with it.
Keep each line as a li and you can give your li a class:
li {
text-align: -webkit-match-parent;
line-height: 20px;
}
.pop-over-part {
position: absolute;
right: -10px;
top: 6px;
height: 100%;
width: 10px;
display: inline-block;
background-image: url(/assets/icons/tab-x.png);
background-repeat: no-repeat;
background-position: top right;
cursor: pointer;
}

Related

trying to make divs with a triangle shape with bootstrap and scss

image1
I am trying to make 3 divs in bootstrap like in this image.Now, I have the code but the problem is, that the before/after elements do not scale with its own div and text.I need to make them responsive, so in small screens, they go one under another.Here is a link withthe bootstrap and scss code: http://www.bootply.com/qYUhoNymFI
The scss code is not applied in your link, so I added classic CSS at the end to show you the way to follow to create triangle.
Here is the code I added :
.shipping,
.support {
position: relative;
background: #d7b789;
color: white;
text-align: center;
}
.returns {
position: relative;
background: black;
color: white;
text-align: center;
}
.shipping:before,
.returns:before,
.returns:after,
.support:after {
content: "";
display: block;
position: absolute;
top: 50%;
-webkit-transform: translateY(-50%);
-moz-transform: translateY(-50%);
-ms-transform: translateY(-50%);
-o-transform: translateY(-50%);
transform: translateY(-50%);
border: solid 32px transparent;
width: 32px;
height: 32px;
}
.returns:before {
left: 0px;
border-left-color: white;
}
.returns:after {
right: 0px;
border-right-color: white;
}
.shipping:before {
right: -64px;
border-left-color: #d7b789;
z-index: 1;
}
.support:after {
left: -64px;
border-right-color: #d7b789;
z-index: 1;
}
Bootply
What I have done here is to set the background colors to match the example.
Then I set the a width, height (equal to the half of the parent div's height) and border to the before and after we want, and set their border-color to transparent.
On each 'before and after, you then define a border-color on the side you want to have the triangle to start.
You then have to place the left and right on the rights elements to place them where you want.
Notice the z-index I added on the first and last block so you are sure the triangles come over the middle block
Now you could translate this to scss to optimize the code.
For example make a mixin for the multiple transform prefixes so you don't have to repeat them everywhere.
Add a variable for the div's height (64px in the example), and use it also for the border-width ($height / 2), and replace the left: -64px; and right: -64px; using this variable too.

How to show the vertical image into horizontal manner using HTML and CSS?

I've one small image displayed along the right edge of the screen. Actually that image is vertical but I want to display it horizontally. How should I achieve this using HTML and CSS?
For your reference following is the screen shot of the page which contains the vertical "Contact" image on right edge bottom side.
Can someone please help me in it?
Following is the code I tried for the vertical position it currently has :
HTML Code :
<div id="new_button_1">
<a href="#" >
<img src="http://www.yourdomain.com/contact.jpeg" alt="" pagespeed_url_hash="3893298907" border="0" align="middle" height="89" width="33">
</a>
</div>
CSS code :
#new_button_1 {
width: 33px;
position: fixed;
right: 0;
top: 85%;
cursor: pointer;
z-index: 7;
}
There is no reason to use an image for such a simple button.
Let's create this with simple CSS:
By default, of course, it is not rotated. You can rotate it with:
transform: rotate(-90deg)
and you can fix it to the same position it currently is using the same CSS and transform-origin: 100% 100% so the rotation is made on the right hand and bottom side and will line up with the viewport.
Further Reading on the MDN
The transform property
The transform-origin property
Working Examples
a {
background: #FCD033;
text-decoration: none;
color: #000;
font-family: sans-serif;
padding: 5px 10px;
}
.rotate {
transform: rotate(-90deg);
display: inline-block;
}
.fixed {
position: fixed;
right: 0;
top: 80%;
cursor: pointer;
z-index: 7;
transform: rotate(-90deg);
transform-origin: 100% 100%;
/*x-offset y-offset = (right hand side and bottom to line up with viewport edge)*/
}
<h2>Not Rotated</h2>
Contact
<h2>Rotated</h2>
Contact
<h2>Fixed (bottom right)</h2>
Contact
You can use CSS3 rotation
transform: rotate(90deg);

css turn right side of an image into an arrow

I have a rectangular sprite image that is 120px x 40px. When someone select the image I want the right side of the selected image to turn into an arrow pointing right.
I know how to use border-radius but that gives a curves whereas I want a point.
Using css how would I turn the right side of an image into a arrow?
Thanks
Basically I want to perform a border-radius only on the right side, but instead of curved pointed like an arrow.
.selected {
-webkit-border-radius: 0px 25px 25px 0px;
border-radius: 0px 25px 25px 0px;
}
If you can keep the white background here is a very simple solution:
jsFiddle here
Run the image in the background of the following example.
HTML
<div class="container"></div>
<div class="container"></div>
<div class="container"></div>
CSS
.container {
background: #333;
width: 200px;
height: 60px;
position: relative;
overflow: hidden;
margin-bottom: 10px;
}
.container:hover::after {
content: "";
position: absolute;
width: 70px;
height: 30px;
background: #fff;
top: -20px;
right: -20px;
z-index: 1;
transform: rotate(45deg);
}
.container:hover::before {
content: "";
position: absolute;
width: 70px;
height: 30px;
background: #fff;
bottom: -20px;
right: -20px;
z-index: 1;
transform: rotate(-45deg);
}
I do not know, i understood your question, but i think, what you want to achive, can be done by jQuery and css function with background-position
Basically, if you want to use a CSS Sprite image, background-position will indeed do it.
You may want to have a <div> positionned over your image, that will be displayed on hovering (CSS :hover) or click (jQuery click event) the image, depending on what you meant by "selecting" it.
Here is an example for hovering case (pure CSS) and here is an example for the clicking case (with 3 lines of jQuery).

Robust Positioning for Vertical Text

This is the design I am currently working on: http://alpha.bounde.co.uk
as you can see each of the ribbon boxes has the title of the box as vertical text (about, work, contact) and I am trying to find the best way to position them so I can have any text of any length and it will appear down the left hand side. At the moment longer text appears to the right as it is rotated from its center. The reason I want it to be done automatically and not just calculate the width is I am using google fonts (which is currently turned off) and if the font isnt loaded in then the text string will be longer / shorter than before and it will again fall out of position.
h2 {
font-family: 'Lato', sans-serif;
font-weight: 300;
font-size: 30px;
color: #793F26;
-webkit-transform: rotate(-90deg);
-moz-transform: rotate(-90deg);
-ms-transform: rotate(-90deg);
-o-transform: rotate(-90deg);
transform: rotate(-90deg);
margin: 0;
padding: 0 10px;
position: absolute;
left: -60px;
top: 100px;
background: #fdfdfd;
display: block;
}
this is the styling I am using for the H2 and there is nothing special in the HTML just the H2 inside a container div which has a border of 30px and a padding of 20px.
anyone have any ideas? thanks
I'd put your headings in a larger container element that's centered on the left border, and center the headings within it.
http://jsfiddle.net/isherwood/sqh95/
body {
padding: 20px;
}
.heading-wrapper {
position: absolute;
width: 150px;
margin-left: -100px;
text-align: center;
}
h2 {
position: relative;
left: 0;
top: 50px;
white-space: nowrap;
}
<div class="heading-wrapper">
<h2>Contact</h2>
</div>
It's best to set transform-origin to something that doesn't change based on the content, such as left top.
You can then use translateX(-100%) to "shift" your content so that you're pivoting around the (fixed) top-right corner. This is easier to work with than trying to rotate around the (variable) top-right corner alone.
So your result would be something like:
transform-origin:left top;
transform:translate(X,Y) rotate(-90deg) translateX(-100%);
Replace translate(X,Y) with the required movement to get the element in position down the left side - it's better to do this than to use left and top, because then it will look acceptable in browsers that don't support transforms.

Create a CSS only Popup, with fade and effect

I want to create a CSS based popup (CSS3 Allowed) without any JavaScript, with a fade transition and scale effect. Something similar to IceCream Sandwitch and JellyBean popup messages.
I have tried the following:
http://jsfiddle.net/OMS_/7UaK4/5/
Main Parts of Code:
HTML
<span class="info"> Info </span>
<div class="message">
<p>
Content
</p>
</div>​
CSS
.message {
position: absolute;
top: 100px;
left: 0;
width: 100%;
text-align: center;
opacity: 0;
-webkit-transform: scale(.9, .9);
-webkit-transition: all .18s ease-in-out;
}
.info:hover + .message {
opacity: 1;
-webkit-transform: scale(1, 1);
}
What I am doing is setting the opacity of the element to 0, and on hover of a sibling DOM element, transtion it to 1.
How do I position it in center, both vertically and horizontally?
Also, is this the proper way to make a CSS3 popup?
Can I transition from display: none to display: block ?
Thanks
How do I position it in center, both vertically and horizontally?
Essentially, you would push the popup 50% from the top and left. However, you must go backwards a bit, since you must take into account the width and height of the popup.
.center-of-screen {
position: absolute;
top: 50%; margin-top: /* -(height/2) */;
left: 50%; margin-left: /* -(width/2) */;
}
Source: How to center an object exactly in the center?
Note: -(height/2) and -(width/2) are negative values of half of element's width and height. E.g. if your element is 300px x 200px code is:
.center-of-screen {
position: absolute;
top: 50%; margin-top: -100px;
left: 50%; margin-left: -150px;
}
Also, is this the proper way to make a CSS3 popup?
Yes, if you are talking about a hover popup.
Can I transition from display: none to display: block ?
No. You would go from display: none to display: block with transition only on opacity.
This is possible now by using visibility:
.message {
visibility: hidden;
opacity: 0;
transform: scale(.9);
transition: transform .18s, opacity .18s, visibility 0s .18s; // delay visibility
}
.info:hover + .message {
visibility: visible;
opacity: 1;
transform: scale(1);
transition-delay: 0s;
}