Going Over the Div Width? - html

I have a set width for my div in CSS, however, I need something inside of that div to go beyond that width, but can't find a solution. Here's my CSS:
#wrapper {
width: 845px;
margin: 0 auto;
}
#wrapper #content {
width: 630px;
float: left;
}
#wrapper #content .post {
background-image: url('images/black_linen_v2.png');
padding: 10px;
color: white; text-shadow: black 0.1em 0.1em 0.2em;
position: relative;
-webkit-border-radius: 10px;
-moz-border-radius: 10px;
}
#wrapper #primary {
color: white;
}
#wrapper #primary .widget-container {
color: white; text-shadow: black 0.1em 0.1em 0.2em;
padding: 10px;
background-image:url('images/black_linen_v2.png');
position: relative;
-webkit-border-radius: 10px;
-moz-border-radius: 10px;
}
And here's what I need to go beyond that area:
/* This is the ribbon effect */
.ribbon {
background: #36ff36;
background: -moz-linear-gradient(top, #36ff36, #21b521);
background: -webkit-gradient(linear, left top, left bottom, from(#36ff36), to(#21b521));
padding: 10px 10px;
margin-left: 50px;
margin-top: 0;
position: relative;
width: 100%;
-moz-box-shadow: 1px 1px 3px #292929;
-webkit-box-shadow: 1px 1px 3px #292929;
/*round the top corners */
-webkit-border-top-left-radius: 10px ;
-webkit-border-top-right-radius: 10px;
-moz-border-top-left-radius: 10px ;
-moz-border-top-right-radius: 10px ;
border-top-right-radius: 10px ;
border-top-left-radius: 10px ;
color: #454545;
text-shadow: 1px 1px 0 #36ff36;
text-align:center;
}
.arrowl {
width: 0; height: 0;
line-height: 0;
border-left: 20px solid transparent;
border-top: 10px solid #21b521;
top: 104%;
left: 0;
position: absolute;
}
.arrowr {
width: 0; height: 0;
line-height: 0;
border-right: 20px solid transparent;
border-top: 10px solid #21b521;
top: 104%;
right: 0;
position: absolute;
}
#footer {position: relative;
background-image:url('../images/footer.png');
margin-top: -150px; /* negative value of footer height */
height: 150px;
clear:both;}
/* End of ribbon effect*/
The set width conflicts with the ".ribbon", which I need to go beyond that set width.
Help is appreciated!

Please post your HTML it it will be a guessing game. However in if you want to create some items which is outside its container, you need to set overflow property on the container.

Set overflow:visible on #wrapper and use a width that is larger (110%) for .ribbon or padding.

You could set the object as fixed position. Then define the position and dimensions. Be sure your parent container has the property overflow:visible. your child element will look like this
position: fixed;
width:*;
height:*;

Related

Displaying a DIV on top of a Textarea element

I have a small "floating_Note_DIV" which I want to display on top of a textarea, as shown in the pictures. As well, I want to show a yellow_DIV below the textarea, flushed with the bottom edge of the textarea. If I do not display the floating_Note_DIV, the textarea is flushed with yellow_DIV (seen below in Image_1).
However, if I display the floating_Note_DIV, a gap appears between the textarea and the yellow_DIV ; i.e., I was thinking that if I put position: relative, and top and left/right I would get the f_N_DIV to fly over the textarea. It does seem to work however it looks like a gap is left where the "footprint" of the f_N_Div is left behind, at it's "supposed-to-be" position between tomato_DIV and yellow_DIV (see below Image_2).
If I use position "Absolute" it gets positioned w.r.t to the whole page, I am expecting the tomato_DIV to move around and so the f_N_DIV will have to be positioned w.r.t the textarea or tomato_DIV.
Any workaround? Thanks, all help appreciated ! !
the HTML is:
<div id='tomato_DIV' >
<textarea id="textarea_main" cols="40" rows="3" maxlength="300"></textarea>
<div id="floating_Note_DIV">Your Thoughts!!</div>
<div id="yellow_DIV"></div>
</div>
the relavant CSS is:
#tomato_DIV
{ background-color: tomato;
padding: 0px 0px 5px 0px;
width: 310px;
border-radius: 5px; }
#textarea_main
{ box-sizing: border-box;
margin: 5px 5px 0px 5px; padding: 2px; /* note: bottom margin is 0 to make flush with yellow div */
width: calc(100% - 10px);
height: 75px;
resize: none; outline: none;
border: 1px solid #737d96; border-radius: 3px; }
#floating_Note_DIV
{ margin: 0px 0px 0px 0px;
padding: 0px 2px 0px 0px;
position: relative; /* how to do this bit? */
right: -232px;
top: -14px;
width: 70px;
height: 11px;
font-size: 8px; font-style: normal; font-weight: bold; color: black;
text-align: right; border: 1px solid #737d96; }
#yellow_DIV
{ margin: 0px 5px 5px 5px; /* note: top margin is 0 to make flush with textarea */
border: 1px solid grey;
border-radius: 3px;
width: calc(100% -10px);
height: 30px; background-color: #fdffb6; }
Is this what you are trying to achieve?
HTML : Put the #floating_Note_DIV element inside #yellow_DIV. You could leave it where it is, but setting top CSS property would have been difficult.
CSS :
Change position property of #floating_Note_DIV from relative to absolute.
Set position property of #yellow_DIV to relative.
Set right to 0.
Set bottom to 100%.
I modified the margin-bottom to 5px to align it perfectly.
#tomato_DIV {
background-color: tomato;
padding: 0px 0px 5px 0px;
width: 310px;
border-radius: 5px;
}
#textarea_main {
box-sizing: border-box;
margin: 5px 5px 0px 5px;
padding: 2px;
/* note: bottom margin is 0 to make flush with yellow div */
width: calc(100% - 10px);
height: 75px;
resize: none;
outline: none;
border: 1px solid #737d96;
border-radius: 3px;
}
#floating_Note_DIV {
margin: 0px 0px 5px 0px;
padding: 0px 2px 0px 0px;
position: relative;
position: absolute;
right: 0;
bottom: 100%;
width: 70px;
height: 11px;
font-size: 8px;
font-style: normal;
font-weight: bold;
color: black;
text-align: right;
border: 1px solid #737d96;
}
#yellow_DIV {
margin: 0px 5px 5px 5px;
/* note: top margin is 0 to make flush with textarea */
border: 1px solid grey;
position: relative;
border-radius: 3px;
width: calc(100% -10px);
height: 30px;
background-color: #fdffb6;
}
<div id='tomato_DIV'>
<textarea id="textarea_main" cols="40" rows="3" maxlength="300">
</textarea>
<div id="yellow_DIV">
<div id="floating_Note_DIV">Your Thoughts!!</div>
</div>
</div>

Adding a triangle in css under another element

I have been trying hard without success to add a little triangle under my square to act as a pointer like this:
My code by itself works, but whenever I try to add css to make this triangle nothing will appear. I think it has to do with before-after functions, but I'm not really getting it. Anyone can help me with that?
<div id="slider_outer1">
<div class="slider_segment"><img src="myurl.com" alt="Nature" style="width:100%;"></div>
<div id="slider_marker1"></div>
</div>
<style>
.container {width:400px;}
#slider_outer1 {width: 98%;border: 5px solid #8f89ff; position: relative;display: inline-block; border-radius: 5px;}
.slider_segment {width: 100%; float: left; display: inline;}
#slider_marker1 {
position: absolute;
border: 2px solid #574fff;
height: 30px;
width: 5%;
top: 120px;
left: 57.25%;
text-align: center;
Margin-left: -10%;
padding: 5px 0px;
background: #ffffff;
border-radius: 5px;
}
div#slider_marker1:after {
content: "5";
font-size: 20px;
padding: 5px;
line-height: 30px;
font-family: sans-serif;
}
</style>
edit: code of the triangle
<div class="triangle-down"></div>
<style>
.triangle-down {
width: 0;
height: 0;
border-left: 15px solid transparent;
border-right: 15px solid transparent;
border-top: 20px solid #555;
}
</style>
Generally in CSS triangles are made using borders, not before and after pseudo elements. To create a downward pointing triangle, you would create a top border of n number of pixels, and left and right borders of half that width and also transparent.
Example:
<div id="slider_outer1">
<div class="slider_segment"><img src="myurl.png" alt="Nature" style="width:100%;"></div>
<div id="slider_marker1"><div id='triangle-down'></div></div>
</div>
<style>
.container {width:400px;}
#slider_outer1 {width: 98%;border: 5px solid #8f89ff; position: relative;display: inline-block; border-radius: 5px;}
.slider_segment {width: 100%; float: left; display: inline;}
#slider_marker1 {
position: absolute;
border: 2px solid #574fff;
height: 30px;
width: 5%;
top: 120px;
left: 57.25%;
text-align: center;
Margin-left: -10%;
padding: 5px 0px;
background: #ffffff;
border-radius: 5px;
}
#triangle-down {
position: absolute;
top: 40px;
right: 50%;
transform: translateX(50%);
width: 0;
height: 0;
border-left: 10px solid transparent;
border-right: 10px solid transparent;
border-top: 20px solid blue;
}
div#slider_marker1:after {
content: "5";
font-size: 20px;
padding: 5px;
line-height: 30px;
font-family: sans-serif;
}
</style>
See my codepen here: https://codepen.io/anon/pen/bvXOab
You could add another div for the triangle like
<div id='triangle'></div>
Css For the triangle...
#triangle{
width: 0;
height: 0;
border-left: 40px solid transparent;
border-right: 40px solid transparent;
border-top: 80px solid blue;
}
However I feel that your problem is not that it just isnt appearing its that the positioning is messed up so its 'hidden' behind the sliders
I think I understand what you're trying to make. This should add a triangle above the marker. This solution should allow you to also remove anything related to triangle-down as it only requires the slider_marker1 div
#slider_marker1::before {
content: "";
width: 0;
height: 0;
position: absolute;
top: -6px;
left: 0;
right: 0;
margin: auto;
border-left: 4px solid transparent;
border-right: 4px solid transparent;
border-bottom: 4px solid green;
z-index: 100;
}

How to create a pricetag shape in CSS and HTML

So I've found this answer - CSS3 menu shape, style but have no idea on how to put it on the left side. I've searched for it already but with no luck.
This is what I'm trying to achieve:
And I've found this one also - Change the shape of the triangle. How can I make it work on the opposite side? I mean the arrow needs to be on the left side. And is it possible to do this with one div?
Want one that you can put over any background color?
jsBin demo
Only this HTML:
<span class="pricetag"></span>
And this CSS:
.pricetag{
white-space:nowrap;
position:relative;
margin:0 5px 0 10px;
displaY:inline-block;
height:25px;
border-radius: 0 5px 5px 0;
padding: 0 25px 0 15px;
background:#E8EDF0;
border: 0 solid #C7D2D4;
border-top-width:1px;
border-bottom-width:1px;
color:#999;
line-height:23px;
}
.pricetag:after{
position:absolute;
right:0;
margin:1px 7px;
font-weight:bold;
font-size:19px;
content:"\00D7";
}
.pricetag:before{
position:absolute;
content:"\25CF";
color:white;
text-shadow: 0 0 1px #333;
font-size:11px;
line-height:0px;
text-indent:12px;
left:-15px;
width: 1px;
height:0px;
border-right:14px solid #E8EDF0;
border-top: 13px solid transparent;
border-bottom: 13px solid transparent;
}
which basically follows this principles: How to create a ribbon shape in CSS
If you want to add borders all around:
jsBin demo with transform: rotate(45deg) applied to the :before pseudo
.pricetag{
white-space:nowrap;
position:relative;
margin:0 5px 0 10px;
displaY:inline-block;
height:25px;
border-radius: 0 5px 5px 0;
padding: 0 25px 0 15px;
background:#E8EDF0;
border: 1px solid #C7D2D4;
color:#999;
line-height:23px;
}
.pricetag:after{
position:absolute;
right:0;
margin:1px 7px;
font-weight:bold;
font-size:19px;
content:"\00D7";
}
.pricetag:before{
position:absolute;
background:#E8EDF0;
content:"\25CF";
color:white;
text-shadow: 0 0 1px #aaa;
font-size:12px;
line-height:13px;
text-indent:6px;
top:3px;
left:-10px;
width: 18px;
height: 18px;
transform: rotate(45deg);
border-left:1px solid #C7D2D4;
border-bottom:1px solid #C7D2D4;
}
Since the example image in the question has extra outer borders, achieving it with the border trick will involve multiple (pseudo) elements and will become complex (because in addition to the arrow shape, a circle is also needed in front). Instead, the same could be achieved by using transform: rotate() like in the below sample.
The approach is pretty simple and as follows:
The parent div container houses the text that should be present within the price-tag shape.
The :after pseudo-element has transform: rotate(45deg) and produces the triangle shape. This is then positioned absolutely with respect to the left edge of the parent. The background set on the pseudo-element prevents the left border of the parent container from being visible.
The :before pseudo-element forms the circle present on the left side (using border-radius).
The X mark at the end is added using a span tag and the × entity.
The parent div container's width is set to auto so that it can expand based on the length of the text.
Note: This sample uses transforms, so will require polyfills in lower versions of IE.
div {
position: relative;
display: inline-block;
width: auto;
height: 20px;
margin: 20px;
padding-left: 15px;
background: #E8EDF2;
color: #888DA3;
line-height: 20px;
border-radius: 4px;
border: 1px solid #C7D2DB;
}
div:after,
div:before {
position: absolute;
content: '';
border: 1px solid #C7D2DB;
}
div:after { /* the arrow on left side positioned using left property */
height: 14px;
width: 14px;
transform: rotate(45deg);
background: #E8EDF2;
border-color: transparent transparent #C7D2DB #C7D2DB;
left: -6px;
top: 2px;
}
div:before { /* the circle on the left */
height: 4px;
width: 4px;
border-radius: 50%;
background-color: white;
left: 0px;
top: 7px;
z-index: 2;
}
.right { /* the x mark at the right */
text-align: right;
margin: 0px 4px;
}
<script src="https://cdnjs.cloudflare.com/ajax/libs/prefixfree/1.0.7/prefixfree.min.js"></script>
<div>Home<span class='right'>×</span>
</div>
<div>Home Sweet Home<span class='right'>×</span>
</div>
<div>Hi<span class='right'>×</span>
</div>
Fiddle Demo
I wanted a simplified version of what was proposed here (without the hole effect and borders) but with the pointing side of it with rounded corner as well. So I came up with this solution. Visually this is what you get:
The HTML for it:
<div class="price-tag">Marketing</div>
<div class="price-tag">Sales</div>
<div class="price-tag">Inbound</div>
And the CSS for it:
.price-tag {
background: #058;
border-radius: 5px;
color: #fff;
cursor: pointer;
display: inline-block;
font-size: 0.875rem;
height: 30px;
line-height: 30px;
margin-right: 1rem;
padding: 0 0.666rem;
position: relative;
text-align: center;
}
.price-tag:after {
background: inherit;
border-radius: 4px;
display: block;
content: "";
height: 22px;
position: absolute;
right: -8px;
top: 4px;
-ms-transform: rotate(45deg); /* IE 9 */
-webkit-transform: rotate(45deg); /* Chrome, Safari, Opera */
transform: rotate(45deg);
width: 22px;
z-index: -1;
}
.price-tag:hover {
background: #07b;
}
original example
Modified: http://jsbin.com/ruxusobe/1/
Basically, it needs to float left, use border-right (instead of left) and modify the padding.
CSS:
.guideList{
font-size: 12px;
line-height: 12px;
font-weight: bold;
list-style-type: none;
margin-top: 10px;
width: 125px;
}
.guideList li{
padding: 5px 5px 5px 0px;
}
.guideList .active{
background-color: #0390d1;
color: white;
}
.guideList .activePointer{
margin-top: -5px;
margin-bottom: -5px;
float: left;
display: inline-block;
width: 0px;
height: 0px;
border-top: 11px solid white;
border-right: 11px solid transparent;
border-bottom: 11px solid white;
}
HTML:
<ul class="guideList">
<li><a>Consulting</a></li>
<li class="active"><span class="activePointer"></span>Law</li>
<li><a>Finance</a></li>
<li><a>Technology</a></li>
</ul>
Here is a simple example...
Orignal Version
Edited Version
CSS:
div {
margin-left: 15px;
background: #76a7dc;
border: 1px solid #CAD5E0;
padding: 4px;
width:50px;
position: relative;
}
div:after {
content:'';
display: block;
position: absolute;
top: 2px;
left: -1.3em;
width: 0;
height: 0;
border-color: transparent #76a7dc transparent transparent;
border-style: solid;
border-width: 10px;
}
Notice on border-color, only right is set with a color and everything else is set to transparent.
using pseudo element and a little bit playing with border you can achieve the exact thing. Check the DEMO.
HTML code is :
<a class="arrow" href="#">Continue Reading</a>
CSS Code is:
body{padding:15px;}
.arrow {
background: #8ec63f;
color: #fff;
display: inline-block;
height: 30px;
line-height: 30px;
padding: 0 12px;
position: relative;
border-radius: 4px;
border: 1px solid #8ec63f;
}
.arrow:before {
content: "";
height: 0;
position: absolute;
width: 0;
}
.arrow:before {
border-bottom: 15px solid transparent;
border-right: 15px solid #8ec63f;
border-top: 15px solid transparent;
left: -15px;
}
.arrow:hover {
background: #f7941d;
color: #fff;
border-radius: 4px;
border: 1px solid #f7941d;
}
.arrow:hover:before {
border-bottom: 15px solid transparent;
border-top: 15px solid transparent;;
border-right: 15px solid #f7941d;
}

Grow progression bar width from right to left

I have a progression bar that when I increase the width of it, it goes from left to right . Like 0% it's on the left of my bar and 100% it's the far right of my bar.
I wonder if it's any way that I could make my progress bar "grow" from right to left.Something like "-100%".
This is my html code:
<div class="completion-bar1-wraper">
<div class="completion-bar1"></div>
</div>
And the css:
div.completion-bar1-wraper{
height: 12px;
border: 1px solid #aaa;
border-radius: 7px;
background: #eee;
box-shadow: 0px 0px 5px 0px #C2C2C2 inset;
margin-right: 4%;
margin-left: 3%;
margin-top: 19%;
}
div.completion-bar1{
height: 8px;
margin: 1px;
border-radius: 7px;
background: #cf7400;
width: 70%;
}
I set up a fiddle with my bar too : Progress Bar
You can do it easily with positioning. Set the container to be position: relative;, absolutely position the progress bar and then specify right: 0; to place it against right edge of the container.
div.completion-bar1-wraper {
/*...*/
position: relative;
}
div.completion-bar1 {
/*...*/
width: 70%;
position: absolute;
right: 0;
}
Here is a fiddle.
There's many ways to do this, so to answer your question, yes.
I've forked your code and adjusted css slightly as follows: http://jsfiddle.net/adamfullen/69mJ8/
div.completion-bar1-wraper{
height: 12px;
border: 1px solid #aaa;
border-radius: 7px;
background: #eee;
box-shadow: 0px 0px 5px 0px #C2C2C2 inset;
margin-right: 4%;
margin-left: 3%;
margin-top: 19%;
position: relative;
}
div.completion-bar1{
position: absolute;
right:0;
height: 8px;
margin: 1px;
border-radius: 7px;
background: #cf7400;
width: 70%;
}
Just edit the completion-bar1 to following
div.completion-bar1{
float: right;
height: 8px;
margin: 1px;
border-radius: 7px;
background: #cf7400;
width: 70%;
}

How to make edgy corners with css

Does anyone know how to make edgy corners like in the following below? See how the edge wraps around the corner. I would like to know the term as well (if any). cross browser support (IE8 and up, bonus IE7) is a must. Thanks for any help.
Check out this tutorial. I don't know how crossbrowser compatible it is (as it is CSS3), but it achieves the effect you want.
HTML:
<div>
<h2></h2>
</div>
CSS:
div {
width: 200px;
padding: 50px;
margin: 0 auto;
border: 1px solid #333;
}
h2 {
position: relative;
width: 50%;
height: 50px;
margin: 30px 10px 10px -70px;
background-color: orange;
}
h2:after {
content: ' ';
position: absolute;
width: 0;
height: 0;
left: 0px;
top: 100%;
border-width: 5px 10px;
border-style: solid;
border-color: #666 #666 transparent transparent;
}
JS Fiddle Example
.box{
background: #666;
border: 4px solid #fff;
box-shadow: 0px 0px 20px #000;
width: 200px;
height: 200px;
margin: 40px auto;
position: relative;
}
.ribbon{
background: #FFA500;
position: absolute;
width: 100%;
top: 20px;
left: -20px;
height: 20px;
padding-right: 20px;
}
.ribbon::before{
content: '';
position: absolute;
left: 0px;
top: 20px;
width: 0px;
height: 0px;
border-style: solid;
border-width: 0 16px 10px 0;
border-color: transparent #FFA500 transparent transparent;
z-index: -5;
}
HTML:
<div class="box">
<div class="ribbon"></div>
</div>
(DEMO)
I don't think IE 7/8 support the ::before pseudo-element, so if you want IE compatibility add another element and put ::before styles on it :)
That edgy corner is only a div with a triangle actually, you only need ONE element to do it.
<div id="myCorner"></div>
myCorner will be the div, and myCorner:after will be the triangle.
Check it out : http://jsfiddle.net/Starx/Xp6E7/2/
#myCorner
{
width:100px;
height:70px;
background-color:orange;
-webkit-box-shadow: 0 4px 5px -3px black;
-moz-box-shadow: 0 4px 5px -3px black;
box-shadow: 0 4px 5px -3px black;
position:relative;
}
#myCorner:after
{
content:"";
position:absolute;
left: 0;
top:100%;
width: 0px;
height: 0px;
border-style:solid;
border-width: 5px 10px;
border-color: orange orange transparent transparent;
z-index: -1;
}