html css sticky, etc - html

For the code below, I have two problems:
The background image cereal.jpeg was working, now for some reason, it's disappeared and I can't figure why. Because it used to work, I know the file name and location are correct.
My controls refuse to remain sticky!
div.container {
border-style: solid;
border-width: thin;
border-color: grey;
box-shadow: 10px 15px 8px black;
height: 1500px;
width: 700px;
}
div.container::before {
background-image: url("cereal.jpeg");
background-repeat: repeat;
opacity: 0.05;
}
div.controls {
float: left;
width: 140px;
border: 1px solid lightgrey;
position: -webkit-sticky; // Safari
position: sticky;
top: 0;
}
div.thePlots {
float: left;
border: 1px solid lightgrey;
width: 400px;
height: 1400px;
}
<div id=container class=container>
<div class=controls id=controls>
<label id="brand">Brand:</label>
<br>
<select size=7 id="brandOptions" multiple>
<option value=0 selected>All</option>
<option value=1>Kellog</option>
<option value=2>Post</option>
<option value=3>Quaker</option>
<option value=4>General Mills</option>
<option value=5>Tree House</option>
<option value=6>CPW</option>
</select>
<br><br><br>
<label id="barsLabel">Error Bars:</label>
<input id=barsPresent type=checkbox value="Error Bars" checked>
<br><br><br>
<label id="label">Elasticity<br>Means:</label>
<br>
<select id="plotY">
<option value="efm" selected="selected">efm</option>
<option value="enm">enm</option>
</select>
<br><br><br>
</div>
<div class=thePlots id=thePlots>
The Plots<br>
<div class="tooltip" id="tooltip"></div>
<div id="plotshare" class="plotshare"></div>
<div id="plotprice" class="plotprice"></div>
<div id="plotsugar" class="plotsugar"></div>
<div id="plotmushy" class="plotmushy"></div>
</div>
</div>

opacity is too low.
Remove float:left;

Your div.controls element is sticking just fine, but it's sticking to the top of your container element. If you put it outside out your container element you will see it stick to the top of the page as desired.
Also, you will need to remove the // safari from your css. The correct syntax for commenting in css is /* comment */
For the background issue, there is no content for your background to display behind. You will need to add something to the before in order for the background to show.
Check this working fiddle which solves both problems
: https://jsfiddle.net/c5vrhf7t/1/

Related

How To Change Color Using CSS

how do I change the colour using CSS?
.container .input-group .opt-group {
width: 100%;
height: 100%;
border: 3px solid #ece5e5;
padding: 15px 20px;
font-size: 1rem;
border-radius: 30px;
background: transparent;
outline: none;
transition: .3s;
}
<html>
<body>
<div class="container">
<div class="input-group">
<select class="opt-group" name="gender" id="gender" required type="">
<option disabled selected required value="">Choose Your Gender</option>
<option value="male">Male</option>
<option value="female"> Female</option>
<option value="other">Other</option>
</select>
</div>
</div>
</body>
</html>
After I applied CSS, it wouldn't change. What's the problem? Please give me a solution, and thanks in advance.
change color of what?
if text color is what you want then
color: red
add this to your css
If you want to change the background color of the container you can use below
background: blue; or background-color:blue;
If you want to change text color
color: green ;

Form Inputs Not Aligned

So I've come across an issue with my input box going out of bounds and I have no idea how to fix it. My select box and input box have the exact same CSS code. I've tried using max-width and vertical-align but both didn't work. Also tried using display: inline-block.
The difference between the 2 are exactly 4px even though both are set to 80% width
HTML
<form class="container_filterSelection">
<label>Product Category</label>
<select class="categorySelect">
<option value="0"></option>
<option value="1">Drills</option>
<option value="2">More Drills</option>
<option value="3">Give me them drills</option>
</select><br>
<label>Address</label>
<input type="text" class="locationSelect">
<button class="submit">Submit</button>
</form>
</html>
CSS
form {
width: 75%;
margin: auto;
background: white;
}
/* Category Dropdown */
.categorySelect {
width: 80%;
margin: 16px 10%;
padding: 16px 0;
}
/* Location Input */
.locationSelect {
width: 80%;
margin: 0 10% 16px 10%;
padding: 16px 0;
}
Try like this:
form {
width: 75%;
margin: auto;
background: white;
}
/* Category Dropdown */
.categorySelect {
width: 80%;
margin: 16px 10% 16px 10%;
padding: 16px 0;
}
/* Location Input */
.locationSelect {
width: 80%;
margin: 0 10% 16px 10%;
padding: 16px 0;
box-sizing: border-box;
}
<form class="container_filterSelection">
<label>Product Category</label>
<select class="categorySelect">
<option value="0"></option>
<option value="1">Drills</option>
<option value="2">More Drills</option>
<option value="3">Give me them drills</option>
</select><br>
<label>Address</label>
<input type="text" class="locationSelect">
<button class="submit">Submit</button>
</form>
Adding box-sizing: border-box; to .locationSelect appears to fix it. The browser's user agent stylesheet appears to be adding this property to select elements but not to input, so to make them look the same, you need to correct for that.

Showing two selection boxes side by side

I have the following code which I wrote:
<div class="selectAorB" *ngIf="this.objects.length > 1">
<div>
<select (change)="this.AorB($event)">
<option value="None" >None</option>
<option value="A" >A</option>
<option value="B" >B</option>
</select>
</div>
</div>
<div class="selectNOT" *ngIf="this.objects.length == 1">
<div>
<select (change)="this.notChange($event)">
<option value="None" >None</option>
<option value="NOT" >NOT</option>
</select>
</div>
</div>
The css:
.selectAorB{
width: 50px;
margin-left: 370px;
margin-top: -41px;
border: 1px solid rgba(88, 109, 140, 0.5);
border-radius: 4px;
padding: 3px;
}
.selectAorB select{
display: block;
width: 50px;
background-image: url('../../../assets/icons/select_arrow.png');
background-repeat: no-repeat;
background-position: right center;
border: none;
-webkit-appearance: none;
-moz-appearance: none;
overflow:hidden;
color: #1A3763;
font-family: Roboto, Arial, Helvetica, sans-serif;
font-weight: normal;
Opacity: 70%;
}
.selectNOT{
width: 50px;
margin-left: 370px;
margin-top: -41px;
border: 1px solid rgba(88, 109, 140, 0.5);
border-radius: 4px;
padding: 3px;
}
.selectNOT select{
display: block;
width: 50px;
background-image: url('../../../assets/icons/select_arrow.png');
background-repeat: no-repeat;
background-position: right center;
border: none;
-webkit-appearance: none;
-moz-appearance: none;
overflow:hidden;
color: #1A3763;
font-family: Roboto, Arial, Helvetica, sans-serif;
font-weight: normal;
Opacity: 70%;
}
Currently, the code adds the selection boxes. If there are multi objects than it will show a box which user can choose None, A or B.
If there is only one object it will add a box which allows to use None or NOT.
The feature I'm trying to implement is to add the second box (None/NOT) beside the first box, in cases there are more than one object, so the HTML should look like:
<div class="selectAorB" *ngIf="this.objects.length > 1">
<div class="selectNOT" *ngIf="this.status == 'NOT'">
<div>
<select (change)="this.notChange($event)">
<option value="None" >None</option>
<option value="NOT" >NOT</option>
</select>
</div>
<br>
</div>
<div>
<select (change)="this.AorB($event)">
<option value="None" >None</option>
<option value="A" >A</option>
<option value="B" >B</option>
</select>
</div>
</div>
<div class="selectNOT" *ngIf="this.objects.length == 1">
<div>
<select (change)="this.notChange($event)">
<option value="None" >None</option>
<option value="NOT" >NOT</option>
</select>
</div>
</div>
But the problem I have is to change the CSS. Every property that I tried to change lead to strange behavior (boxes not in their places). I'm not sure which change I should make so it could work as expected (two boxes one by one). Hoping to hear some guidelines about what to do.
I am not sure that you actually need to have those divs in the first place, but perhaps you need those for something else you intend to do that is out of the context of this question. Also, a lot of your CSS seems unnecessary without seeing the rest of your source, such as the negative margins. So for the sake of simplicity I will ignore all of that.
To get both of the divs containing your selects onto the same line, simple float them with float: left such as in the following example:
.inline {
float: left;
margin-right: 5px;
}
<div class="selectAorB inline">
<div>
<select>
<option value="None" >None</option>
<option value="A" >A</option>
<option value="B" >B</option>
</select>
</div>
</div>
<div class="selectNOT inline">
<div>
<select>
<option value="None" >None</option>
<option value="NOT" >NOT</option>
</select>
</div>
</div>

<select> tags are not staying within specified borders in Firefox

I am creating an app the requires me to use 3 <select> tags that are stacked on top of each other. I need said tags to be flush with each other and also not leap over the background div's boundaries. I am making this work out fine in Google Chrome, but when I check it out Firefox, everything goes haywire. The select tags are nearly over the boundaries of the background div in unacceptable ways.
A visual example of my problem (Firefox on left Google Chrome on right)...
Here is my HTML...
<div id='wr-main-wrap'>
<div id='wr-wrapper'>
<div id='wr-opaq-background'></div>
<div id='input-wrapper'>
<div>
<h3 class='label-text'>work day length:</h3>
<select ng-model='ratioControl.workday'>
<option value='1'>1 Hour</option>
</select>
</div>
<div>
<h3 class='label-text'>break frequency:</h3>
<select ng-model='ratioControl.breakspan'>
<option value='.5'>30 Minutes</option>
</select>
</div>
<div>
<h3 class='label-text'>break lengths:</h3>
<select ng-model='ratioControl.breaklength'>
<option value='5'>5 Minutes</option>
</select>
</div>
</div>
</div>
</div>
Here is my CSS...
#wr-main-wrap{
width: 19em;
margin: 0 auto;
}
#wr-wrapper{
width: 17em;
margin: 3.5em auto;
}
#wr-opaq-background{
position: absolute;
width: 17em;
height: 7em;
background-color: white;
z-index: -1;
opacity: .7;
border-radius: .25em;
}
#input-wrapper{
margin: 5em 0;
padding: .85em 0 0 .6em;
}
.label-text{
font-family: 'Bebas Neue';
margin-bottom: .8em;
word-spacing: .1em;
display: inline-block;vertical-align: top;
width: 9em;
}
select{
width: 6em;
margin: 0 0 1.1em 0;
background-color: white;
border: black solid .1em;
}
I have check on stack overflow and the internets quite a bit, and have not found anything to answer my question. It is worth nothing that I am using Angular in case that may have something to do with it.
Try the following CSS:
#wr-wrapper{
position: relative;
}
The <input> tags themselves needed a height and width, otherwise, they would just adjust to the browser's default settings. This is completely unpredictable. I used % as a unit of measurement.

background color not filling entire div

I am having a problem in filling the entire center content (div) with a background color.
I want to fill element with id body-content with the blue color but its not actually stretching to full height.
HTML code
<div id="body-content">
<iframe id="promo-video" width="40%" height="315" src="" frameborder="0" allowfullscreen style="margin-bottom: 20px;"></iframe>
<script language="javascript" type="text/javascript">
$(document).ready(function(){
var y_pos = $('#search-panel').position().top;
$('#promo-video').css('top',y_pos);
});
function sho(a){
if (a=='1'){
document.getElementById('criteria-1').style.display = "block";
document.getElementById('criteria-2').style.display = "none";
document.getElementById('criteria-3').style.display = "none";
}
else if (a=='2'){
document.getElementById('criteria-1').style.display = "none";
document.getElementById('criteria-2').style.display = "block";
document.getElementById('criteria-3').style.display = "none";
}
else if (a=='3'){
document.getElementById('criteria-1').style.display = "none";
document.getElementById('criteria-2').style.display = "none";
document.getElementById('criteria-3').style.display = "block";
}
}
</script>
<div id="search-boxes">
<div id="search-panel">
<form id="search-form" name="search-form" onsubmit="return false;">
<fieldset style="margin-bottom:8px;">
<legend><i>Find By</i></legend>
<input type="radio" name="sp" onclick="sho(1);" checked/>A
<input type="radio" name="sp" onclick="sho(2);"/>B
<input type="radio" name="sp" onclick="sho(3);"/>C
</fieldset>
<p>
<select name="spe" id="criteria-1">
<option value="g">G</option>
<option value="c">C</option>
<option value="ge">Ge</option>
</select>
<input type="text" style="width:97%;vertical-align:center;display:none;height:24px;padding-left:8px;" placeholder="Or find a.." id="criteria-2"/>
<input type="text" style="width:97%;vertical-align:center;display:none;height:24px;padding-left:8px;" placeholder="Or find b.." id="criteria-3"/>
</p>
<select name="city" style="width:49%;">
<option value="any-city">In City</option>
<option value="mumbai">Mumbai</option>
<option value="nyc">New York</option>
</select>
<select name="locality" style="width:49%;">
<option value="anywhere">Near Area</option>
<option value="vasant-vihar">Vasant Vihar</option>
<option value="andheri">Andheri</option>
</select>
<br><br>
<input type="submit" class="button_g" name="submit-search" value="Search for A">
</form>
</div>
</div><!-- End of Search boxes -->
</div><!-- End of body content -->
CSS code
#search-boxes{
margin: 40px;
display: inline-block;
float: right;
margin-right: 8%;
clear: both;
width: 450px;
}
#search-panel{
border: 6px solid #c6e7f8;
}
#search-panel{
text-align: center;
padding: 30px;
padding-top: 20px;
padding-bottom: 20px;
width: 400px;
background-color: #ffffff;
font-family: "Segoe UI Semibold", sans-serif;
}
#search-boxes select{
width: 100%;
height: 30px;
}
#promo-video{
position: absolute;
margin-left: 8%;
border: 6px solid #d9d9d9;
}
#body-content{
background-color: #e9f6fc;
/* background: linear-gradient(to bottom, #e9f6fc 50%, white);
background: -webkit-linear-gradient( to bottom, #e9f6fc 50%, white);
background: -moz-linear-gradient( to bottom, #e9f6fc 50%, white);
background: -o-linear-gradient( to bottom, #e9f6fc 50%, white);
*/ margin-top: 0px;
margin-bottom: 0px;
margin-left: 0px;
margin-right: 0px;
padding: 40px;
vertical-align: middle;
}
I tried searching for the problem and found a solution, that clear should be used to make floating items behave normally. But that too doesn't work. What am I missing?
Another problem was with the linear gradient, I wanted blue to extend till 50% height, but that fills upto 90%, when the blue color fills the entire body-content.
Try this:
#body-content {overflow: hidden;}
That forces the body-content div to wrap around its floated contents. There are other methods for enclosing floats, but this tends to be the easiest.
Note, however, that because your iframe is set to position: absolute;, nothing will clear that except a height on the container, which is rarely a good idea. It would be better to float that too.
First off, that code doesn't generate anything like that screenshot for me (frame is on top of the search boxes and the blue background goes further down).
But replacing the position:absolute; in the #promo-video style to float: left; and adding another float:left to #search-boxes generated something similar to what you have.
In that situation, correcting your issue is simply a matter of adding <div style="clear:both;"></div> below the closing tag for search-boxes>
i.e.
Use floats to get the layout you want.