Displaying a DIV on top of a Textarea element - html

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>

Related

CSS change height on :hover

I am trying to change the height and position of an anchor <a> on hover.
The CSS I am using is:
.options {
background: linear-gradient(#FFFFFF, #dbe2e8);
display: table-cell;
vertical-align: middle;
text-align: center;
width: 115px;
height: 35px;
border: 1px solid black;
border-bottom: none;
border-radius: 8px 8px 0px 0px;
-moz-border-radius: 8px 8px 0px 0px;
}
.options:hover {
height: 39px;
top: -4px;
}
I must be doing something wrong. I have tried the :hover part with just the top: -4px; and this works, however the height: 39px; does nothing.
Thanks
Add position: relative also because top, right, bottom and left properties work only when applied with position relative, absolute or fixed.
.options {
background: linear-gradient(#FFFFFF, #dbe2e8);
display: table-cell;
vertical-align: middle;
text-align: center;
width: 115px;
height: 35px;
border: 1px solid black;
border-bottom: none;
border-radius: 8px 8px 0px 0px;
-moz-border-radius: 8px 8px 0px 0px;
position: relative;
}
.options:hover {
height: 39px;
top: -4px;
}
Link
While Muhammad Usman's answer works just fine, I'd like to offer an alternative.
If you replace the top:-4px with translateY(-4px) that will work regardless of the "position" property of the element and/or the "top" property.
(Useful if for example the "top" property is a percentage or set dynamically by JS and you want to move it by 4 pixels no matter what the top is)
.options {
background: linear-gradient(#FFFFFF, #dbe2e8);
display: table-cell;
vertical-align: middle;
text-align: center;
width: 115px;
height: 35px;
border: 1px solid black;
border-bottom: none;
border-radius: 8px 8px 0px 0px;
-moz-border-radius: 8px 8px 0px 0px;
}
.options:hover {
height: 39px;
transform:translateY( -4px);
}

CSS rounded corner element fails in IE11

I'm basically trying to do a "CSS-triangle" (you know, an element where the entire shape is generated using borders) but instead of a triangle shape, I want a square with rounded corners on the left side and straight corners on the right side.
This works fine in Chrome but IE11 creates a weird artefact at the top-left corner. (a background-colored oval right where the rounded corner should be. really strange!)
Is there a way to create a workaround for IE11?
.RoundedElement {
width: 0;
height: 0;
border-top: none;
border-bottom: 50px solid transparent;
border-right: 20px solid #00a2d4;
position: relative;
right: 20px;
border-radius: 15px 0px 0px 15px;
border-color: #F7A824;
}
http://codepen.io/anon/pen/QbjaOG
I think you are over complicating the problem here.
Try the following:
body { margin: 50px; }
.RoundedElement {
width: 30px;
height: 50px;
position: relative;
right: 20px;
border-radius: 15px 0px 0px 15px;
background-color: #F7A824;
}
<div class="RoundedElement">
</div>
Why not use the regular background-color with border radius that works by default ?
If you still want to use border try the following:
body { margin: 50px; }
.RoundedElement {
width: 20px; //Added 20px to fix in FF.
height: 0px;
border-top:30px solid transparent;
border-bottom: 30px solid transparent;
border-right: 40px solid #00a2d4;
position: relative;
border-radius: 15px 0px 0px 15px;
border-color: #F7A824;
}
<div class="RoundedElement">
</div>
tweaking the code to:
body { margin: 50px; }
.RoundedElement {
width: 10px;
height: 0;
border-top:30px solid transparent;
border-bottom: 30px solid transparent;
border-right: 10px solid #00a2d4;
position: relative;
right: 20px;
border-radius: 15px 0px 0px 15px;
border-color: #F7A824;
z-index:2
}
pen
works in FF (should also in ie but not tested)
There is no need to do it like this. Use border-radius (support here). Also what you have is not a square, this is.
div {
width: 100px;
height: 100px;
border-radius: 50% 0px 0px 50%;
background: #000;
}
<div></div>
It not work because your div size is 0: width: 0; height: 0;

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%;
}

Going Over the Div Width?

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:*;

Margin-top of not working on unfloated element

I have a parent div #modal_share that contains a floating div modal_big_hline and a unfloated div modal_big_button_container (with clear: both).
modal_big_button_container's CSS is created to allow it to be the width of the parent div minus 25px on its left and right sides.
Problem: Changing the margin-top of modal_big_button_container does not cause it to shift up/down, instead it remains in the same position, although its margin can be seen to be changing using Chrome's developer tools.
Why is this happening, and how can I solve this? Thanks!
CSS
#modal_share {
width: 565px;
height: 400px;
position: relative;
background: whiteSmoke;
padding-top: 10px;
-webkit-border-radius: 10px;
-moz-border-radius: 10px;
border-radius: 10px;
-webkit-box-shadow: 0px 3px 16px #222;
-moz-box-shadow: 0px 3px 16px #222;
box-shadow: 0px 3px 16px #222;
display: none;
}
.modal_big_hline {
width: 100%;
height: 1px;
margin-top: 25px;
border-top: 1px solid #CCC;
float: left;
}
#modal_big_button_container {
height: 14px;
width: auto;
margin: 10px 25px 0px 25px;
clear: both;
}
HTML Structure
<div id="#modal_share">
<div class="modal_big_hline"></div>
<div id="modal_big_button_container"></div>
</div>
JSFiddle: http://jsfiddle.net/5LG2w/
try
modal_big_button_container{
position: relative;
top: 20px;
}
here is the fiddle - http://jsfiddle.net/5LG2w/2/.
or you can take the float out of .modal_big_hline. then your margin-top will work - http://jsfiddle.net/5LG2w/3/.
#modal_big_button_container {
height: 14px;
width: auto;
margin: 10px 25px 0px 25px;
clear: both;
background: red;
}
Looks like margin collapsing. Check these pages:
http://reference.sitepoint.com/css/collapsingmargins
http://www.howtocreate.co.uk/tutorials/css/margincollapsing