I have a problem. I have CSS styles for 9 buttons on my webpage but #a doesn't work. All the other 8 ones are working fine. (The CSS is paired with HTML and Javascript, I'm trying to make a Tic-Tac-Toe Game.) (Note: I removed some code, because its all the same.)
#a {
position:absolute;
left:50px;
top:150px;
<!-- The Green Text Is Purely For De-bug purposes -->
text-color:green;
}
#b {
position:absolute;
left:150px;
top:150px;
}
#c {
position:absolute;
left:250px;
top:150px;
}
#d {
position:absolute;
left:50px;
top:200px;
}
The problem was the comments, I tried with and without them and it turns out they should be
/* Blaah */
instead of
<!-- Blaah -->
Related
Can we use lighten, Darken CSS attributes without colour value?
I have a class with the background colour
Ex:
.master{
background-color:green;
}
<div class="master">Master</div>
I have to lighten the background of the "Div" using a different CSS class. How can I do that?
Note:
I have a few themes and predefined background colours so I have to use those colours and have a shade of it using a different class
Opacity is not what I'm looking for.
You can consider a pseudo element to create another layer and inherit the background-color then you can apply filter without any issue:
.master{
background-color:green;
}
.master2{
background-color:red;
}
.light,
.dark{
position:relative;
z-index:0;
}
.light:before,
.dark:before{
content:"";
position:absolute;
z-index:-1;
top:0;
left:0;
right:0;
bottom:0;
background-color:inherit;
filter:brightness(200%);
}
.dark:before {
filter:brightness(50%);
}
<div class="master light">Master</div>
<div class="master2 light">Master</div>
<div class="master dark">Master</div>
<div class="master2 dark">Master</div>
You can use the filter CSS property to tweak the brightness as follows:
.master {
background-color: green;
}
.lighten {
filter: brightness(150%);
}
.darken {
filter: brightness(50%);
}
<div class="master">Master</div>
<div class="master lighten">Master lighten</div>
<div class="master darken">Master darken</div>
I think it is quite easy to add a different class so that you can lighten the background of your div element. Try this example,
.master-light{
background-color:rgba(0,0,0,0.5); /*where 0.5 stands for 50% opacity*/
}
This might help you, I think this is the only way to achieve your goal.
As you can see both the images were same, no filter is applied to the content.
.master{
color:#fff;
position:absolute;
top:10px;
left:10px;
}
.mmaster{
-webkit-filter: brightness(200%);
background:green;
position:relative;
padding:80px 0;
}
<div class="mmaster"></div>
<div class="master"><img src="https://www.w3schools.com/css/bgdesert.jpg" alt="desert">Desert</div>
<img src="https://www.w3schools.com/css/bgdesert.jpg">
Can we use lighten, Darken CSS attributes without colour value?
I have a class with the background colour
Ex:
.master{
background-color:green;
}
<div class="master">Master</div>
I have to lighten the background of the "Div" using a different CSS class. How can I do that?
Note:
I have a few themes and predefined background colours so I have to use those colours and have a shade of it using a different class
Opacity is not what I'm looking for.
You can consider a pseudo element to create another layer and inherit the background-color then you can apply filter without any issue:
.master{
background-color:green;
}
.master2{
background-color:red;
}
.light,
.dark{
position:relative;
z-index:0;
}
.light:before,
.dark:before{
content:"";
position:absolute;
z-index:-1;
top:0;
left:0;
right:0;
bottom:0;
background-color:inherit;
filter:brightness(200%);
}
.dark:before {
filter:brightness(50%);
}
<div class="master light">Master</div>
<div class="master2 light">Master</div>
<div class="master dark">Master</div>
<div class="master2 dark">Master</div>
You can use the filter CSS property to tweak the brightness as follows:
.master {
background-color: green;
}
.lighten {
filter: brightness(150%);
}
.darken {
filter: brightness(50%);
}
<div class="master">Master</div>
<div class="master lighten">Master lighten</div>
<div class="master darken">Master darken</div>
I think it is quite easy to add a different class so that you can lighten the background of your div element. Try this example,
.master-light{
background-color:rgba(0,0,0,0.5); /*where 0.5 stands for 50% opacity*/
}
This might help you, I think this is the only way to achieve your goal.
As you can see both the images were same, no filter is applied to the content.
.master{
color:#fff;
position:absolute;
top:10px;
left:10px;
}
.mmaster{
-webkit-filter: brightness(200%);
background:green;
position:relative;
padding:80px 0;
}
<div class="mmaster"></div>
<div class="master"><img src="https://www.w3schools.com/css/bgdesert.jpg" alt="desert">Desert</div>
<img src="https://www.w3schools.com/css/bgdesert.jpg">
Everywhere on web I found that multiple css classes use a space as separator.
So, I'm write the following:
<div class="page hidden">
css
.hidden{
display:none;
}
Using the above code .hidden IS NOT hidden, but visible.
But using:
<div class="page, hidden">
.hidden IS hidden.
Any explanation !?
You were doing everything correct. The only explanation is that you have something else affecting it that you haven't put in your question.
Just to prove it works:
div {
height:300px;
width:300px;
position:relative;
border-radius:150px;
line-height:300px;
text-align:center;
}
div div {
height:150px;
width:150px;
border-radius:75px;
position:absolute;
top:75px;
left:75px;
line-height:150px;
}
.green {
background-color:green;
}
.red {
background-color:red;
color:white;
}
.hidden {
display:none;
}
.visible:hover .hidden {
display:block;
}
<div class="green visible">
<div class="red hidden">
hidden div
</div>
hover here
</div>
the stacking order of your css will effect the styles that are applied. Also the specificity of the tags used will effect what you see from the front end.
so as an example:
/* .hidden is ignored in this example because .page comes after the hidden tag */
.hidden {display:none;}
.page {display: block;}
/* where as this will hold as it's more specific to the page, so will take a higher priority */
body .hidden{display: none;}
/* or this as it's more specific to the exact tags above */
.page.hidden {display: none;}
Just for example:
.page{ display:block}
.hidden{
display:none!important;
}
jsFiddle: https://jsfiddle.net/r1us08a3/2/
Currently I'm having a solution, but I'm almost certain that there's a better solution out there. Basically I'm having a block-element and want to align some of the text at the beginning of my block and some at the end.
Here's a little jsfiddle example
What I'm doing is using float and 2 more block-elements inside to align it:
<div id="block">
<div id="start">1</div>
-
<div id="end">12</div>
</div>
#block {
text-align:center;
background: #000;
color: white;
width:150px;
}
#start {
float:left;
}
#end {
float:right;
}
I have many of those little objects, so my code is bloated with div's. Is there no more lightweight solution for this out there ?
I fiddled a possible answer based on the answer to this question.
http://jsfiddle.net/ScHdJ/2/
Works in all browsers, as far as I can see...
May be you can use CSS :after & :before pseudo classes like this:
HTML:
<div id="block">
hello
**</div>
CSS:**
#block {
text-align:center;
background: #000;
color: white;
width:150px;
overflow:hidden;
}
#block:before{
content:"1";
float:left;
}
#block:after{
content:"12";
float:right;
}
http://jsfiddle.net/ScHdJ/3/
But is not work in IE7 & below.
Helllo, I have this html code
<div class="tf">
<img src="images/facebook.png" width="2%" class="tfimg">
</div>
and for the CSS
.tf {
float:right;
margin-right:65px;
margin-top:-30px;
padding:2px;
}
.tfimg {
position:absolute;
z-index:-1;
border:none;
}
to be the image out of the border but I can't click in the image so what's the problem and what's the solution for that ?
Both of your images have the same class assigned to them. You are stacking them on top of each other by not setting them to different positions and the facebook.com one appears on top since it is last in the html. If you want them to appear beside each other you can apply something like the following:
.tftwitter {
position:absolute;
left:0px;
border:none;
}
.tffacebook {
position:absolute;
left: 20px;
border:none;
}
And now assign each image the appropriate class.
try using:
.tf{
display:inline-block;
/* your more code */
}