when hover the box, other box display-block is not working - html

#c_w {background-color:rgba(0, 0, 0, 0.5);;
width:55px;
height:25px;
color:white;
text-align:center;
padding-top:3px;
position:absolute;
margin-top:38px;
margin-left:-12px;
display:none;}
#c_w:hover {display:block;}
.color_td {height:27px;
width:27px;
margin:2px;
border-radius:5px;}
<div class="color_td" style="background-color:white;float:left; border:1px solid #c2c2c2"></div>
<div id="c_w">White</div>
i wanna make #c_w box showing when i hover .color_td box.
why is it not work???
any help will be so appreciated.
Thank you

If you remove the a tag as .color_td's parent, then you access #c_w like this-
.color_td:hover + #c_w {
display:block
}
#c_w {
background-color:rgba(0, 0, 0, 0.5);;
width:55px;
height:25px;
color:white;
text-align:center;
padding-top:3px;
position:absolute;
margin-top:38px;
margin-left:-12px;
display:none;
}
.color_td {
height:27px;
width:27px;
margin:2px;
border-radius:5px;
}
<div class="color_td" style="background-color:white;float:left; border:1px solid #c2c2c2"></div>
<div id="c_w">White</div>
Or if you want to keep the a tag as .color_td's parent, then you could achieve the desired effect with Javascript-
let color_td = document.querySelector('.color_td');
let c_w = document.querySelector('#c_w');
// listen for 'mouseenter' event
color_td.addEventListener('mouseenter',()=> {
c_w.style.display = "block"
});
// listern for 'mouseleave' event
color_td.addEventListener('mouseleave', ()=> {
c_w.style.display = "none"
});
#c_w {background-color:rgba(0, 0, 0, 0.5);;
width:55px;
height:25px;
color:white;
text-align:center;
padding-top:3px;
position:absolute;
margin-top:38px;
margin-left:-12px;
display:none;}
.color_td {height:27px;
width:27px;
margin:2px;
border-radius:5px;}
<a href="#">
<div class="color_td" style="background-color:white;float:left; border:1px solid #c2c2c2"></div>
</a>
<div id="c_w">White</div>

your doing wrong here,
#c_w {background-color:rgba(0, 0, 0, 0.5);;
width:55px;
height:25px;
color:white;
text-align:center;
padding-top:3px;
position:absolute;
margin-top:38px;
margin-left:-12px;
display:none;} /* <- */
#c_w:hover {display:block;} /* <- */
As, You cant hover on a hidden element
instead you wanna do something like this,
1. keeping ur html un-touched
#c_w {
background-color: rgba(0, 0, 0, 0.5);
width: 55px;
height: 25px;
color: white;
text-align: center;
padding-top: 3px;
position: absolute;
margin-top: 38px;
margin-left: -12px;
display: none;
}
a:hover + #c_w { /* ModifiedCss */
display: block;
}
.color_td {
height: 27px;
width: 27px;
margin: 2px;
border-radius: 5px;
}
<a href="#">
<div class="color_td" style="background-color:white;float:left; border:1px solid #c2c2c2"></div>
</a>
<div id="c_w">White</div>
2. move the #c_w under .color_td
#c_w {
background-color: rgba(0, 0, 0, 0.5);
width: 55px;
height: 25px;
color: white;
text-align: center;
padding-top: 3px;
position: absolute;
margin-top: 38px;
margin-left: -12px;
display: none;
}
.color_td:hover #c_w { /* ModifiedCss */
display: block;
}
.color_td {
height: 27px;
width: 27px;
margin: 2px;
border-radius: 5px;
}
<a href="#">
<div class="color_td" style="background-color:white;float:left; border:1px solid #c2c2c2">
<div id="c_w">White</div> <!-- ModifiedHtml -->
</div>
</a>
Here, i thing is, you gotta, wrap the hidden element in something that visible (hoverable), and edit style properties of that targted hidden element by making it child or sibling or soemthing like that...

Related

decrease brightness of image without affecting elements on image

I am a beginner working on a front end project with HTML and CSS where on my website I have a welcoming picture which I include below :
I try to adjust the brightness of the image for better contrast using filter:brightness() on my image
However when I apply filter:brightness(50%); the brightness of the image obviously decreases but I lose the display of my logo on the left and my navbar on the right. I do not understand why this is happening and I would appreciate your help. My code :
.html,.body{
background-size: cover;
}
body{
overflow-x: hidden;
margin:0;
background: rgba(0, 0, 0, 0.1);
font-family: Arial, Helvetica, sans-serif;
}
.welcome-container{
position: relative;
top:0px;
left: 0px;
width:100%;
height:550px;
margin:0px;
background-position: center;
background-repeat: no-repeat;
background-size: cover;
}
.welcome-pic{
position: relative;
}
.welcome-pic h5{
position: absolute;
top:0%;
left:6%;
}
#fly{
font-size: 55px;
}
.welcome-pic img{
background: linear-gradient( rgba(0, 0, 0, 0.5), rgba(0, 0, 0, 0.5) ), url('file:///Volumes/Animus/Jon/Dropbox/website/hellcity.jpg');
}
#welcome-plane{
filter: brightness(50%);
}
#book{
position: relative;
background-color: white;
border: none;
color: black;
padding: 15px 32px;
text-align: center;
text-decoration: none;
display: inline-block;
font-size: 16px;
top:50%;
left:30%;
cursor: pointer;
}
.square-container{
position: absolute;
top: 2px;
left: 2%;
}
.ds-square{
background-color: red;
height: 50px;
width:50px;
opacity:1;
}
.ds-square span{
position: relative;
top:30%;
left:27%;
color:white;
font-size:20px;
}
.welcome-pic img {
width:100%;
height:550px;
opacity: 1;
}
.inside-pic{
position:absolute;
top:30%;
left:50%;
font-size: 60px;
transform: translate(-50%, -50%);
}
.welcome-pic ul{
position: absolute;
top:2px;
right:0%;
margin:0;
padding:0;
overflow:hidden;
background-color: transparent;
}
.welcome-pic li{
float:left;
display: block;
color: white;
text-align: center;
padding: 14px 16px;
text-decoration: none;
font-size:20px;
}
.inside-pic h3{
font-size:18px;
}
<div class = "welcome-container">
<div class = "welcome-pic">
<h5>DS <br/> AIRLINES</h5>
<div class="square-container">
<div class="ds-square">
<span id = "DS">DS</span>
</div>
</div>
<ul>
<li><a class="active" href = "#home">Home</a></li>
<li>News</li>
<li>About</li>
<li>Contact</li>
</ul>
<img src = "IMAGES/welcome_pic.jpg" alt="#" id = "welcome-plane">
<div class = "inside-pic">
<span id = "fly">FLY WITH DS <br/> AIRLINES</span>
<h3>Flights from or towards Athens ! Fly secure and comfortable with us! </h3>
<button id = "book">Book flight</button>
</div>
</div>
</div>
Thank you in advance.
You can use below code in your css (made image as background of div)
.welcome-pic{
background-image: linear-gradient(rgba(0,0,0,0.4),rgba(0,0,0,0.4)), url("IMAGES/welcome_pic.jpg") no-repeat center;
background-size: cover;
}
Make sure you remove img tag from your html.
You can adjust rgba values (alpha values) to specify brightness level.
It looks like you have a z-index layering issue. Use this css:
.welcome-pic{
z-index:0;
}
.square-containerĀ {
z-index: 1;
}
.welcome-pic ulĀ {
z-index: 1;
}
Here is the codepen: https://codepen.io/ladywebhawk/pen/NWNPNzN

onclick Overlay effect

I just need to add a overlay effect on clicking the three dots. It should display a white background on top of that, transition should be from bottom.
I have attached the codepen link.
To preview your work...
Use this codepen link....
https://codepen.io/subin_s/pen/NVgLgx
HTML
<link rel="stylesheet" href="https://use.fontawesome.com/releases/v5.8.2/css/all.css">
<div class="projects">
<div class="image">
</div>
<div class="words">
<h2>BlogSpire</h2>
<i class="fas fa-ellipsis-v" id="moreinfo"></i>
<div class="clearfix"></div>
<p>Blogging web app created for the Engineering team at WeSpire.</p>
</div>
</div>
CSS
* {
margin:0;
padding:0;
box-sizing:border-box;
}
body {
font-family:'Roboto';
}
.projects {
position:relative;
margin:2rem;
width: 335px;
height:400px;
background-color:#fff;
border-radius:5px;
box-shadow: 0 2px 5px 0 rgba(0,0,0,0.16), 0 2px 10px 0 rgba(0,0,0,0.12);
}
.image {
position:absolute;
width:100%;
height:240px;
background-color:skyblue;
}
.words {
position:absolute;
top:240px;
padding:20px 20px 30px;
color:#333;
}
.words i {
position:absolute;
top:27px;
right:40px;
cursor:pointer;
}
.words h2 {
color:#008073;
}
.words p {
padding:13px 0 0;
}
JS
document.getElementById('moreinfo').addEventListener('click', projectInfo);
function projectInfo() {
}
You can add the overlay by adding a element commonly a div inside of your card, and setting its position to absolute. You can position it around using the top, left, bottom or right attributes.
To create the animation of the overlay comming from the bottom, you can create a simple css transition, changing the values of the top css attribute.
I've edited your code to create a small example on top of it. I hope it helps you.
const moreInfoElement = document.getElementById('moreinfo');
const overlay = document.getElementById('overlay');
moreInfoElement.addEventListener('click', projectInfo);
function projectInfo() {
overlay.classList.add('active-overlay');
setTimeout(() => {
overlay.classList.remove('active-overlay');
}, 3000);
}
* {
margin:0;
padding:0;
box-sizing:border-box;
}
body {
font-family:'Roboto';
}
.projects {
position:relative;
margin:2rem;
width: 335px;
height:400px;
background-color:#fff;
border-radius:5px;
box-shadow: 0 2px 5px 0 rgba(0,0,0,0.16), 0 2px 10px 0 rgba(0,0,0,0.12);
overflow: hidden;
}
.image {
position:absolute;
width:100%;
height:240px;
background-color:skyblue;
}
.words {
position:absolute;
top:240px;
padding:20px 20px 30px;
color:#333;
}
.words i {
position:absolute;
top:27px;
right:40px;
cursor:pointer;
}
.words h2 {
color:#008073;
}
.words p {
padding:13px 0 0;
}
.overlay{
position: absolute;
width: 100%;
height: 100%;
top: 100%;
background-color: rgba(255, 255, 255, 0.9);
z-index: 1;
transition: all .6s;
}
.active-overlay{
top: 0;
}
<link href="https://use.fontawesome.com/releases/v5.8.2/css/all.css" rel="stylesheet"/>
<div class="projects">
<div id="overlay" class="overlay">
Some text
</div>
<div class="image">
</div>
<div class="words">
<h2>BlogSpire</h2>
<i class="fas fa-ellipsis-v" id="moreinfo"></i>
<div class="clearfix"></div>
<p>Blogging web app created for the Engineering team at WeSpire.</p>
</div>
</div>

How to close hover dropdown menu on outside click?

I really do not want to lose the hover capability, I need a way without losing the hover capability.
In pure CSS (no JavaScript), how do I get the dropdown menu to close on clicks outside of the dropdown menu, without losing the hover capability?
Here is an example of someone who did a JavaScript dropdown menu with the feature of closing on outside clicks.
https://koen.kivits.com/articles/pure-css-menu/
Here is my dropdown menu CSS with hover and onClick:
.acn-menu {
text-align: center;
background-color: rgba(0, 0, 0, 0.9);
}
.label_openclose {
display: none;
}
.menu-tabs {
height: 100%;
padding-left: 0;
padding-right: 0;
padding-top: 0;
padding-bottom: 0;
}
/* This CSS makes the Solutions dropdown menu push
down the other two items when in mobile view. */
#media (min-width: 320px) {
.menu-tabs {
position: absolute;
}
}
.menu-tabs .elem {
box-sizing: border-box;
padding: 0 20px;
float: left;
height: 100%;
line-height: 70px;
background-color: rgb(30, 30, 30);
color: white;
}
.menu-check {
display: none;
}
label {
margin-bottom: 0;
}
.label_openclose {
display: inline-block;
width: 60px;
min-height: 50px;
background-color: transparent;
cursor: pointer;
overflow:hidden;
display:block;
}
.menu-tabs .elem {
line-height: initial;
float: initial;
height: 0px;
cursor: pointer;
border-top: 0px solid #000;
overflow: hidden;
}
.menu-check:checked~.menu-tabs .elem {
height: 25px;
color: white;
border-top: 2px solid rgba(255, 255, 255, 0.2);
}
.label_openclose:hover~.menu-tabs .elem {
border-top: 2px solid rgba(255, 255, 255, 0.2);
height: 25px;
}
.label_openclose~.menu-tabs:hover .elem {
border-top: 2px solid rgba(255, 255, 255, 0.2);
height: 25px;
}
Is it possible for me to get the close-on-click without using JS? Here is a fiddle: https://jsfiddle.net/Ld5L2tnf/
I reviewed your code and posted an example of what you want. This is a more simple way of achieving your goal. This is an example you will have to apply it to your code. This is a pure css and html solution using checkboxes and labels. Below is detailed information on how it works. Hope it helps. Enjoy.
<html>
<head>
<title></title>
<style>
.buttoncomtainer1{ /*A wrapper for your hover dropdown List*/
width:100px;
height:2em;
float:left;
position:absolute;
z-index:20;
}
.mycheckButton{ /*Your Label acts as a Button Triggering the checkbox*/
width:100px;
height:2em;
float:left;
display:block;
background-color:blue;
text-align:center;
color:#ffffff;
position:fixed;
z-index:20;
}
.mycheckDrop{ /*Your Dropdown*/
width:100px;
float:left;
display:none;
padding:1%;
background-color:green;
position:fixed;
z-index:20;
margin-top:2em;
}
.gone{ /*Make your checkbox disappear*/
border:0px;
outline:none;
line-height:0;
display:none;
margin:0px;
padding:0px;
width:0px;
height:0px;
}
.blackout{ /*This Div covers the page with the labelBlackout Label in it. nothing can be clicked unless The Label inside clicked first triggering the checkbox. */
width:100%;
height:100%;
float:left;
position:fixed;
z-index:15;
background-color:transparent; /* You can add a background color like this. background-color:black; opacity:0.7;*/
display:none;
}
.labelBlackout{ /*the Label inside the blackout div that covers the page*/
width:100%;
height:100%;
float:left;
}
.lnkCon{ /* Container that holds your dropdown links.*/
width:100%;
height:2em;
float:left;
margin-top:5px;
}
input[type=checkbox].gone:checked ~ div.blackout{display:block;}
input[type=checkbox].gone:checked ~ label.mycheckDrop{display:block;}
.buttoncomtainer1:hover > .mycheckDrop{display:block;}
</style>
</head>
<body>
<div class="buttoncomtainer1">
<input class="gone" id="myCheck" type="checkbox" >
<div class="blackout" ><label class="labelBlackout" for="myCheck"></label></div>
<label class="mycheckButton" for="myCheck">DropDown</label>
<label class="mycheckDrop" for="myCheck">
<span class="lnkCon">Button 1</span>
<span class="lnkCon">Button 2</span>
<span class="lnkCon">button 3</span>
</label></div>
</body>
</html>

How can I place this div next to the other one?

I was wanting to make a website, just to see if I like doing it and how it would turn out, but I can't seem to get this part done. I want the "informatie" div to be next to the "vertmenu" div and make it fill up the white part and I want the "vertmenu" div to extend till the "voetregel" div. I have no idea how to get this done and I have already tried changing the width and height to percentages, changing the positions to absolute/relative and adding a float property, but I couldn't make it how I wanted it to be. So my question in short, how can I make the "informatie" div next to the "vertmenu" div and make it fill up the white part and get the "vertmenu" div to extend till the "voetregel" div.
body {
margin:0;
padding:0;
background-color:#ffffff;
background-repeat: no-repeat;
background-attachment: fixed;
background-position: center;
}
#hormenu {
background-color: rgba(0, 0, 0, 0.5);
position:relative;
text-align: center;
width:100%;
height:15%;
line-height:50px;
font-size:100%;
}
#vertmenu {
background-color: rgba(255,0,0, 0.3);
position:relative;
height:100px;
top:15%;
width:15%;
margin:0px 0px 0px 0px;
padding:3px;
overflow:hidden;
}
#informatie {
background-color: rgba(0,0,255, 0.3);
position:relative;
float:left;
height:100%;
width:85%;
left: calc(15% + 6px);
margin:0px 0px 0px 0px;
padding:3px;
overflow:hidden;
}
#voetregel {
background-color: rgba(0,255,0, 0.3);
position:fixed;
width:100%;
height:100px;
top:auto;
right:0;
bottom:0;
margin-left:10px
}
a.hormenu_item {
margin: 10px;
transition: color 0.3s, text-shadow 0.3s, text-decoration-line 0.3s, font 0.3s ease-in-out;
}
a:link.hormenu_item {
color: white;
text-decoration: none;
}
a:visited.hormenu_item {
color: white;
text-decoration: none;
}
a:hover.hormenu_item {
color: gold;
text-decoration:none;
text-shadow: 0px 0px 7px gold;
font-size: 30px;
}
#informatie h1, #vertmenu h1, #voetregel h2 {
color:#FF0000;
font-size:20px;
}
<body>
<div id="hormenu">
Home
Biografie
Features
Contact
</div>
<div id="vertmenu">
<h1>vertmenu</h1>
</div>
<div id="informatie">
<h1>informatie</h1>
</div>
<div id="voetregel">
<h2>voetregel</h2>
</div>
</body>
apply float:left; css in #vertmenu and #informatie
and dont use position:fixed; in #voetregel use clear:both; it will clear the float effect of above 2 div tags
position:fixed; is used for creating menubar in web site so that even with the scrolling that menubar stays at same place
You can add display: inline-block to make them next to each other. Remove position:fixed from #voetregel too.
#vertmenu {
background-color: rgba(255,0,0, 0.3);
width:15%;
margin:0px 0px 0px 0px;
}
#informatie {
background-color: rgba(0,0,255, 0.3);
width:85%;
margin:0px 0px 0px 0px;
}
#voetregel {
background-color: rgba(0,255,0, 0.3);
width:100%;
height:200px;
}
#vertmenu,
#informatie {
display: inline-block;
float: left;
}
#informatie h1,
#vertmenu h1,
#voetregel h2 {
color:#FF0000;
font-size:20px;
}
<div id="vertmenu">
<h1>vertmenu</h1>
</div>
<div id="informatie">
<h1>informatie</h1>
</div>
<div id="voetregel">
<h2>voetregel</h2>
</div>

My height attribute is showing different results in firefox than all the other browsers (safari,chrome act). Why?

I have a simple layout and the logo appears to be different in firefox and I can't seem to get an even medium in all browsers as when I change the height of the letter 'f' in the blue box it effects all browsers.
The issue i am having is with the div "logofoxfont" as I want the letter 'f' to be in the same position in all broswers but it appears to be different in firefox.
How can I sort this?
<html>
<head>
</head>
<link href="fw.css" rel="stylesheet" type="text/css">
<body>
<div class="topbox">
<div class="logobox"><div class="logoboxfont">
f</div></div>
<div class="logotext"></div>
</div>
<div class="midbox">
<div class="menubox"><div class="menuboxfont">Home<br>About Us<br>Staff<br>News<br></div>
<div class="menubox2"><div class="menuboxfont2">Appointments<br>
Price Guide<br>Emergency Services<br>Feedback<br></div></div></div>
</div>
</body>
</html>
And the css is:
#logo{
background-image:url(40.jpg);
height:100px;
width:100px;
}
.topbox {
margin: 0px auto;
height:100px;
width:900px;
margin-top:0px;
background: #ffffff;
}
.logobox {
height:90px;
width:70px;
margin-top:10px;
background-color:#2FB2F4;
}
.logotext {
color: #333333;
font-family: Cambria;
font-size: 18px;
margin-top: -90px;
margin-left: 75px;
position:absolute;
}
#logotext1 {
margin-left:10px;
}
#logotext2 {
color: #00AAF5;
font-family: georgia;
font-size: 22px;
margin-top: -35px;
margin-left:10px;
}
.logoboxfont {
font-family:Cambria;
color: #ffffff;
font-size: 126px;
position:absolute;
margin-top:-20px;
margin-left:0px;
-moz-transform:rotate(10deg);
-webkit-transform:rotate(10deg);
-o-transform:rotate(10deg);
-ms-transform:rotate(10deg);
}
.midbox {
margin: 0px auto;
height:700px;
width:900px;
margin-top:0px;
background: #ffffff;
border-top: 1px solid #333333;
}
.menubox {
height:230px;
width:150px;
margin-top:10px;
background: #E6E6E6;
}
.menuboxfont {
color: #333333;
font-family:lucida grande;
font-size: 12px;
margin-top: 4px;
margin-left: 4px;
position:absolute;
}
.menubox2 {
height:160px;
width:150px;
margin-top:70px;
background: #FAFAFA;
position:absolute;
}
.menuboxfont2 {
color: #333333;
font-family:lucida grande;
font-size: 12px;
margin-top: 4px;
margin-left: 4px;
position:absolute;
}
Thanks for the help!
James
See fiddle for code and demo:
Fiddle: http://jsfiddle.net/kHtmf/1/
Demo: http://jsfiddle.net/kHtmf/1/embedded/result/
SS of Firefox:
SS of chrome:
SS of Safari: