I am trying to create a div to align with the bottom corner of a form input but with a triangular arrow pointing to the corner and merged into the box. I am having problems creating this as i am not a designer. Basically what i'm looking for is a kind of arrow that merges with the box (maybe like a speech bubble)
Anyway code so far:
html:
<div class="inputwrap">
<select id="gb_contact" name="gb_contact" class="dropdown-input" >
<option value="option">option</option>
</select>
<div class="tip">rrrrrrrrrrr</div>
</div>
css
.inputwrap{
position: relative;
display: inline-block;
min-width: 10%;
}
.tip:before {
position: absolute;
content: " ";
width: 0;
height: 0;
border-style: solid;
border-width: 15px 15px 0 0;
border-color: #00FF00 transparent transparent transparent;
z-index: 100;
left: -0px;
top: -2px;
-ms-transform: rotate(5deg); /* IE 9 */
-webkit-transform: rotate(5deg); /* Chrome, Safari, Opera */
transform: rotate(5deg);
}
.tip {
position: absolute;
right: -190px;
background-color:#ff0000;
min-width:200px;
min-height: 50px;
margin-top:2px;
border-radius:5px;
}
can anyone help with this?
jsfiddle: http://jsfiddle.net/d30top88/
link to concept:
https://drive.google.com/file/d/0B9ZIIks7bG2QT2haMWZZcXM3ZWc/edit?usp=sharing
close enough i suppose :
http://jsfiddle.net/d30top88/4/
What do you mean with merged inside the box? Just adjusted your fiddle like that:
Arrow Demo
with some adjustments:
top: 12px;
-ms-transform: rotate(135deg); /* IE 9 */
-webkit-transform: rotate(135deg); /* Chrome, Safari, Opera */
transform: rotate(135deg);
So it the arrow is now pointed to the right and down in the div.
Update after image link was provided in question:
Arrow Demo 2
But based on the image maybe the arrow has not the appropriate shape to meet your requirements. There are some nice css arrow generators online, just google for "css arrow generator" as I don't want to promote a special one.
Related
I am working on a project which has a custom shape background and an image on top of it. Its located on the Hero area of the landing page. I need a good solution so that the custom shape will be in the background. And the user can change the image or the Color if they needed.
Here is a demo of the shape I am talking about. Is there any way I can achieve it using CSS, and the user can change the image or color later? What do you think of a solution here?
Thanks in advance.
This is actually multiple questions.
How can I layer multiple elements over each other.
How can I change the shape of an html element.
The now deleted answer by Alexandre Beaudet, that you said was 'Not really close to what I wanted', actually did answer the second question clearly and briefly. You were too blinded by the details of what you want to see the principle you needed to learn from that answer.
Given how easy these elements are to research, I don't even want to show you example code, but here's one:
.wrapper {
width: 100%;
height: 300px;
background: gray;
position: relative;
}
.background-shape {
background: orange;
width: 100%;
height: 200px;
-ms-transform: skewY(-20deg);
-webkit-transform: skewY(-20deg);
transform: skewY(-20deg);
border-radius: 30px;
position: absolute;
top: 0px;
left: 50px;
}
.content {
color: white;
position: absolute;
top: 120px;
left: 30%;
z-index: 10;
}
<div class="wrapper">
<div class="content">
Lorem Ipsum Hero
</div>
<div class="background-shape">
</div>
</div>
This is EXAMPLE code. SO is not a copy-paste solution site. It is here to teach you specific mechanisms you were heretofore unaware of to solve specific problems. It just so happens that code snippets can be one of the best ways to explain things in a succinct and clear way.
To implement this on your website you will need to put a LOT of work into this to position and shape everything so that it actually looks good on all devices.
I was finally able to solve this problem on the day I posted it on StackOverflow. Thanks to all the guys who have commented. I used a CSS pseudo element to make this shape.
Here is my code.
// Header Shape
.has-header-shape {
position: relative;
&::before {
position: absolute;
width: 1350px;
height: 550px;
content: "";
background: #0cebeb; /* fallback for old browsers */
background: -webkit-linear-gradient(
to right,
#8cbf86,
#66b4a6,
#408ca3
); /* Chrome 10-25, Safari 5.1-6 */
background: linear-gradient(
to right,
#8cbf86,
#66b4a6,
#408ca3
); /* W3C, IE 10+/ Edge, Firefox 16+, Chrome 26+, Opera 12+, Safari 7+ */
z-index: -1;
top: 0px;
border-radius: 60px;
-webkit-transform: skew(0deg, -15deg);
transform: skew(0deg, -15deg);
left: auto;
right: 0;
}
}
I found this codepen which is using this sprite to add the corners:
with this code:
.lol-promo:before,
.lol-promo:after {
background: url("http://s.cdpn.io/800/ornaments-sprite.png") no-repeat;
content: "";
height: 40px;
position: absolute;
top: 0; left: 0;
width: 95px;
}
.lol-promo:after {
background-position: -95px 0;
left: auto; right: 0;
}
but in the codepen example is using only the top corners, how can i add the bottom corners too, to a simple div? i tried some things like repeating div:after part but is not working. I think its simple but i am not getting the point.
Thanks in advance
You can make use of the CSS3 border-image property.
You define how the image will get sliced and the width of the border. The slice rule takes four values each defining top, right, bottom and left corners of the box respectively. This way, you don't need any pseudo-elements.
Give your markup: <section class="lol-promo"></section>..
All you need is this CSS:
.lol-promo {
...
border-image: url('//s.cdpn.io/800/ornaments-sprite.png');
border-image-slice: 40 96 40 96;
border-image-width: auto;
}
The slice is based off the image that you referenced to in your question. For any other image, you need to tweak those values depending on how you want the border to appear.
Example Snippet:
.lol-promo {
height: 120px; width: 320px; margin: 16px; padding: 16px;
background-color: rgba(0,0,128,0.1);
border-image: url('//s.cdpn.io/800/ornaments-sprite.png');
border-image-slice: 40 96 40 96;
border-image-width: auto;
}
<section class="lol-promo">
<h2>header</h2>
<p>Lorem ipsum</p>
</section>
Example Fiddle: http://jsfiddle.net/abhitalks/05Lx7eea/
You can duplicate that div .lol-promo and flip the bottom ones vertically with transform:scale and absolute position them to the bottom right and left of your page. Here's a fiddle https://jsfiddle.net/az6juLkq/1/ with the full code.
.lol-promo.left,
.lol-promo.right {
position: absolute;
-moz-transform: scale(1, -1);
-webkit-transform: scale(1, -1);
-o-transform: scale(1, -1);
-ms-transform: scale(1, -1);
transform: scale(1, -1);
}
.lol-promo.left{
bottom: 0; left: 0;
}
.lol-promo.right {
bottom: 0; right: 0;
background-position: -95px 0;
right: 0px;
}
In order to accomplish the flip, you can use a CSS transform. This may be done within the pseudo-element itself if you wish.
-moz-transform: scale(1, -1);
-webkit-transform: scale(1, -1);
-o-transform: scale(1, -1);
-ms-transform: scale(1, -1);
transform: scale(1, -1);
In the linked example, notice the border is technically border-top, yet it appears on the bottom.
CODEPEN: http://codepen.io/pohuski/pen/bVBpNw
I know how to use font-awesome and some other css files to get an icon in a button something like the images below.
But now My requirement is to have that icon at the bottom right corner of a button. Something like...
I am Using bootstrap and font-awesome.
create a css class like this and assign it to the icon span:
.bottom-right {
position: absolute;
bottom: 0;
right: 0;
}
Additionally the button needs to have position: relative; assigned, so that the absolute positioned icons coordinates are relative to the button.
Here is a fiddle:
http://jsfiddle.net/8a2jbp7f/2/
If you want a rotated caret like in your image use text roation like #BenW posted.
As Mario and Ben has suggested, I have modified the code in my fiddle to get what i wanted
HTML
<button type="button" class="btn btn-sm btn-default">
My Contacts <span class="caret"></span>
</button>
Css
button {
margin:20px;
position: relative;
}
.caret {
position: absolute;
bottom: 1px;
right: 0px;
/* Safari */
-webkit-transform: rotate(-45deg);
/* Firefox */
-moz-transform: rotate(-45deg);
/* IE */
-ms-transform: rotate(-45deg);
/* Opera */
-o-transform: rotate(-45deg);
}
Final Fiddle
Maybe with css text rotation!?
https://css-tricks.com/snippets/css/text-rotation/
.btmRight .fa-plus {
position: absolute;
right: 0;
bottom: 0;
}
Add this style and check.
I figured out how to add an opening quote marks on my quote (using a background), but how would I add a closing quote marks in my style. I'd like to add a closing quote marks image after the Russell Wilson is a great quarterback.
If I'm not doing it the preferred way, can you suggest the best practices for making this happen?
Jsfiddle
<p>
<span class="inline-quote">Russell Wilson is a great quarterback</span>
Russell Carrington Wilson is an American football quarterback for the Seattle Seahawks of the National Football League. Wilson was selected by the Seahawks with the 12th pick in the third round of the 2012 NFL Draft.
</p>
.inline-quote {
background: url('http://www.pearl-guide.com/forum/images/Eloquent/miscblue/quote_icon.png') left top no-repeat;
background-position: 15% 5px;
}
you can use :before and :after
Demo
.inline-quote:before, .inline-quote:after{
display:inline-block;
width: 20px;
height:20px;
background: url('http://www.pearl-guide.com/forum/images/Eloquent/miscblue/quote_icon.png');
background-repeat: no-repeat;
content: '';
}
.inline-quote:after{
-webkit-transform: rotate(180deg);
-moz-transform: rotate(180deg);
-ms-transform: rotate(180deg);
-o-transform: rotate(180deg);
transform: rotate(180deg);
}
You can only have one background per element. So make a pseudo-element!
.inline-quote { position: relative }
.inline-quote::after { /* Insert it after */
content: ''; /* Required for it to show up */
position: absolute; /* Stretch it */
top: 0; right: 0; bottom: 0; left: 0;
background: url('http://www.pearl-guide.com/forum/images/Eloquent/miscblue/quote_icon.png') left top no-repeat; /* Same background */
background-position: 15% 90%; /* Position it in the lower right */
transform: scaleX(-1); /* Flip it */
-webkit-transform: scaleX(-1);
}
http://jsfiddle.net/bmj942y4/5/
You should also be using the blockquote element. http://jsfiddle.net/bmj942y4/7/
You can use multiples background-image
Example
background-image: url('img1.jpg'), url(img2.jpg);
background-position: 15% 5px, 85% 5px;
Work with
Firefox 3.6+
Safari 1+
Chrome 1.3+
Explorer 9+
Opera 10.5+
More informations
http://www.css3.info/preview/multiple-backgrounds/
Like this. With IE6 compatibility too.
<ul>
<li>Home</li>
<li class="selected">About</li>
<li>Contact Us</li>
<li>Portfolio</li>
<li>Gallery</li>
<ul>​
You can use this jsfiddle example to play with
http://jsfiddle.net/jitendravyas/GN6ed/
and this arrow image http://i.imgur.com/QHFqq.gif
You can use CSS3's transform property to rotate a small box to 45 Deg, and make it look like an arrow.
.arrow {
width: 30px;
height: 30px;
background: #000;
-webkit-transform: rotate(45deg); /* Saf3.1+, Chrome */
-moz-transform: rotate(45deg); /* FF3.5+ */
-ms-transform: rotate(45deg); /* IE9 */
-o-transform: rotate(45deg); /* Opera 10.5 */
transform: rotate(45deg);
filter: progid:DXImageTransform.Microsoft.Matrix(/* IE6–IE9 */
M11=0.7071067811865476, M12=-0.7071067811865475, M21=0.7071067811865475, M22=0.7071067811865476, sizingMethod='auto expand');
zoom: 1;
}
Here is a demo
Update 2: Here is the PURE CSS SOLUTION with the border too.
This wouldn't be easy to accomplish in IE6.
You could use something like this. But it wouldn't be supported in IE6 as it doesn't support the ::before pseudo class.
.selected {
position:relative;
}
.selected::before {
content: "";
position: absolute;
top: 100%;
left: 42%;
width: 0;
height: 0;
border-left: 7px solid transparent;
border-right: 7px solid transparent;
border-top: 13px solid red;
}​
If you decide to do this with just css take a look at this http://www.robjstanley.com/css3-shapes/.
There's a speech bubble shape that you can do with just css3, pretty cool.
I didn't tested it on IE6 but i am sure it's work on it.
Check this http://jsfiddle.net/GN6ed/4/
Simple CSS will do the trick:
.selected a {background:white;
background-image: url(http://i.imgur.com/QHFqq.gif);
background-repeat: no-repeat;
background-position: 50% 0%;
}
Updated fiddle.
Dunno about IE6 can't test it here but I think this is as cross browser as possible, using basic CSS stuff.