CSS: Hovering over child of element should affect different element - html

I want users to be able to hover over a button within a different div, which then changed the background-color of the div below.
My current code is as followed:
.delSeperator button:hover+.linkField {
background-color: rgba(255, 0, 0, 0.2);
}
.seperator {
color: #000000;
background-color: #e4e8eb;
min-height: 0.5rem;
margin: 1rem 0rem 1rem 0rem;
}
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap.min.css" integrity="sha384-BVYiiSIFeK1dGmJRAkycuHAHRg32OmUcww7on3RYdg4Va+PmSTsz/K68vbdEjh4u" crossorigin="anonymous">
<div id="delSeperator_0" class="row delSeperator">
<div class="col-xs-10 mb-0">
<div class='seperator vertical-center'></div>
</div>
<div class="col-xs-1 mb-0"><button type="button" class="btn btn-danger" onclick="delField('linkField', this.closest('.row')); delField('delSeperator', this.closest('.row'));"><i class="fa fa-minus" aria-hidden="true"></i></button></div>
</div>
<div class="row linkField" id="linkField_0">
<div class="col-xs-6 mb-0">
<div class="form-group"><label for="txt_link[0]["bezeichnung"]" class="">Bezeichnung</label><input id="txt_link[0]["bezeichnung"]" type="text" maxlength="200" name="link[0]["bezeichnung"]" class="form-control"></div>
</div>
<div class="col-xs-6 mb-0">
<div class="form-group"><label for="txt_link[0]["url"]" class="">URL</label><input id="txt_link[0]["url"]" type="url" maxlength="500" name="link[0]["url"]" class="form-control"></div>
</div>
</div>
Changing the Hover-CSS to
.delSeperator:hover + .linkField {
background-color: rgba(255,0,0,0.2);
}
works so that when you hover over the whole .delSeperator, the .linkField gets the background property.
When I change the code to
.delSeperator button:hover {
background-color: rgba(255,0,0,0.2);
}
it works so that when you hover over the button, the button gets the background property.
But I can't seem to combine these two. Is there any way to achieve what I need?

You can workaround this issue by playing with the pointer-events property
i got this to work with the following CSS:
.delSeperator:hover + .linkField {
background-color: rgba(255,0,0,0.2);
}
.delSeperator {
pointer-events: none
}
.delSeperator button {
pointer-events: initial
}

Related

How can I disable it so that when I open the download-popup the background doesn't move with it? - Chrome

Whenever the download-popup gets open my chat-box stays static but the background size is moving with the messages dynamically.
so if the curser is at the bottom it moves a little high as soon as the download popup is open
I tried to make the position:fixed, height:100% or the z-index +/-10
Unfortunately, I had to cut a few lines of code away so I could post it.
HTML:
<div id="chatContent{{i}}" class="row chat-content">
</div>
<hr>
<div class="row mb-3 mt-2">
<div class="col-12 input-group">
<input id="userInput{{i}}" #userInput (keyup.enter)="sendMessage(userInput)"
class="form-control form-control-lg"
type="text" placeholder="Ask me something">
<div class="input-group-append">
<button mat-button
class="c-white bc-darkgreen bgc-darkgreen w-px-100 btn-left-no-round"
(click)="sendMessage(userInput);">
<i *ngIf="sendBlock;then loader else send"></i>
<ng-template #loader>
<fa class="fa fa-spin fa-2x" name="spinner"></fa>
<span class="sr-only">Sent!</span>
</ng-template>
<ng-template #send>
Send
</ng-template>
</button>
</div>
</div>
</div>
CSS:
.chat-block {
background-color: white !important;
border-radius: 5px;
}
.chat-content {
overflow-y: auto;
max-height: 75vh;
height: calc(75vh - 100px);
min-height: calc(75vh - 100px);
box-sizing: border-box;
order: -10;
}
.chat-margin {
margin-left: 5px;
margin-right: 15px;
}

center and put a larger text area in Boostrap 4

I am using Bootstrap 4 and have some issues:
Center the input-fiels (inline)
space between these inputs
add a larg textarea under the input-fiels
This is what it looks like currently:
Here is my HTML code:
body {
background: url(https://images.pexels.com/photos/50631/pexels-photo-50631.jpeg?cs=srgb&dl=aerial-bridge-buildings-50631.jpg&fm=jpg);
background-size: cover;
background-position: center;
font-family: Lato;
color: white;
}
html {
height: 100%;
}
#content {
text-align: center;
padding-top: 25%;
text-shadow: 0px 4px 3px rgba(0, 0, 0, 0.4), 0px 8px 13px rgba(0, 0, 0, 0.1), 0px 18px 23px rgba(0, 0, 0, 0.1);
}
h1 {
font-weight: 700;
font-size: 5em;
}
hr {
width: 400px;
border-top: 1px solid #f8f8f8;
border-bottom: 1px solidrgba(0, 0, 0, 0.2);
}
input.transparent-input {
background-color: transparent;
border: 2px solid white;
}
.form-control::placeholder {
color: white;
}
/* Chrome, Firefox, Opera*/
:-ms-input-placeholder.form-control {
color: white;
}
/* Internet Explorer*/
.form-control::-ms-input-placeholder {
color: white;
}
/* Microsoft Edge */
.no-padding {
padding-right: 50px;
padding-bottom: 10px;
}
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>Zenuni Company</title>
<link href="https://fonts.googleapis.com/css?family=Lato" rel="stylesheet">
<link rel="stylesheet" href="bootstrap.css">
<link rel="stylesheet" href="app.css">
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/font-awesome/4.7.0/css/font-awesome.min.css">
<script src="https://maxcdn.bootstrapcdn.com/bootstrap/4.0.0-alpha.6/js/bootstrap.min.js" integrity="sha384-vBWWzlZJ8ea9aCX4pEW3rVHjgjt7zpkNpZk+02D9phzyeVkE+jo0ieGizqPLForn" crossorigin="anonymous"></script>
</head>
<body>
<div class="container h-100">
<div class="row h-100 justify-content-center align-items-center">
<div class="col-12">
<div id="content">
<h1>Contact Page</h1>
<h3>Contact Us</h3>
<hr>
</div>
<form class="form-inline">
<div class="form-group">
<input class="form-control transparent-input" type="text" name="name" placeholder="Name" required>
</div>
<div class="form-group">
<input class="form-control transparent-input" type="text" name="surname" placeholder="Vorname" required>
</div>
</form>
<button type="submit" class="btn btn-default">Send invitation</button>
</div>
</div>
</div>
I would appreciate your help!
You can do it in two ways.
the first one is using grid system, this will work in this way:
<div class="container">
<div class="row">
<div class="col-sm">
One of three columns
</div>
<div class="col-sm">
One of three columns
</div>
<div class="col-sm">
One of three columns
</div>
</div>
</div>
The second way that i think will fit better, I'm find this way more helpful when talking about responsive center.
<div class="row">
<div class="col-md-6 offset-md-3">.col-md-6 .offset-md-3</div>
</div>
Hope i could help :)
I just edited your code and added to jsfiddle
your form should be like this to achieve center inputs with margins :
<form class="form-inline justify-content-center">
<div class="form-group space-right">
<input class="form-control transparent-input" type="text" name="name" placeholder="Name" required>
</div>
<div class="form-group space-right">
<input class="form-control transparent-input" type="text" name="surname" placeholder="Vorname" required>
</div>
<button type="submit" class="btn btn-default my-2 my-sm-0">Send invitation</button>
</form>
with this line of css :
.space-right {margin-right:10px;}
You do not need to use justify-content-center for the row because col-12 takes the whole row.
Instead of form-inline, use two form-row classes inside the form - one for the two inputs and the other for the button. And use a col for each of the inputs should you like to have them side by side on all kinds of devices. Otherwise, use col-* classes as you normally would, for instance, use col-12 col-sm-6 so that they takes the whole width of its parent on mobile but half on other devices. And then use a col class for the button.
You may also swap .row for .form-row, a variation of our standard grid row that overrides the default column gutters for tighter and more compact layouts. - Bootstrap-4
Restrict the width of the form only. In order to do so, use custom CSS as you have done so. If you do so, use mx-auto for the form to center it horizontally inside its container.
Should you like to have the button in the center of its parent, use text-center for its parent.
https://codepen.io/anon/pen/KBWXME
One more thing, I guess you have used align-items-center to align all the content vertically in the center. If so, use h-100 for all the parents of the container. Otherwise, align-items-center won't work.
body {
background: url(https://images.pexels.com/photos/50631/pexels-photo-50631.jpeg?cs=srgb&dl=aerial-bridge-buildings-50631.jpg&fm=jpg);
background-size: cover;
background-position: center;
font-family: Lato;
color: white;
}
html,
body {
height: 100%;
}
#content {
text-align: center;
text-shadow: 0px 4px 3px rgba(0, 0, 0, 0.4), 0px 8px 13px rgba(0, 0, 0, 0.1), 0px 18px 23px rgba(0, 0, 0, 0.1);
}
h1 {
font-weight: 700;
font-size: 5em;
}
hr {
width: 400px;
border-top: 1px solid #f8f8f8;
border-bottom: 1px solidrgba(0, 0, 0, 0.2);
}
input.transparent-input {
background-color: transparent;
border: 2px solid white;
}
.form-control::placeholder {
color: white;
}
/* Chrome, Firefox, Opera*/
:-ms-input-placeholder.form-control {
color: white;
}
/* Internet Explorer*/
.form-control::-ms-input-placeholder {
color: white;
}
.mw-500px {
max-width: 500px;
}
<link href="https://cdnjs.cloudflare.com/ajax/libs/twitter-bootstrap/4.1.2/css/bootstrap.css" rel="stylesheet" />
<div class="container h-100">
<div class="row h-100 align-items-center">
<div class="col">
<div id="content">
<h1>Contact Page</h1>
<h3>Contact Us</h3>
<hr>
</div>
<form class="mw-500px mx-auto">
<div class="form-row">
<div class="col-12 col-sm-6 form-group">
<input class="form-control transparent-input" type="text" name="name" placeholder="Name" required>
</div>
<div class="col form-group">
<input class="form-control transparent-input" type="text" name="surname" placeholder="Vorname" required>
</div>
</div>
<div class="form-row ">
<div class="col-12 col-sm-6 form-group">
<button type="submit" class="btn btn-default">
Send invitation</button>
</div>
</div>
</form>
</div>
</div>
</div>
Your input fields are not centered because they're not part of your #content element. If you move the first </div> tag after <div id="content"> below your submit button, that should take care of that issue.
I'm not sure what exactly you're looking for in terms of space between your input fields. You could just use the </br> tag to make a space, but that will probably be a little ugly. I'd recommend going into your CSS code, selecting .form-inline and messing around with the padding until you're satisfied with how it looks
I don't know exactly what you're trying to do, maybe I could help if you sketched a mock-up of what you're thinking of.
Hope this is useful!

Horizontal Radio Buttom Custom Design

I been trying to reach this design radio button design with no success
I'm using bootstrap for my site, but all I can reach is this:
This is my code:
.content {background-color: #42d5b9; padding: 50px}
.amount-landing {text-align: center;}
.amount-landing label {color: #FFFFFF;}
.amount-landing > .col-xs-2 {background: url(https://i.imgur.com/K8Nz8Y2.png) repeat-x; background-position: 0 12px;}
.amount-landing input[type="radio"] {
display:none;
}
.amount-landing input[type="radio"] + label span {
display:inline-block;
width:15px;
height:15px;
margin:0px 0px 0 0;
vertical-align:middle;
background: #FFFFFF;
cursor:pointer;
border-radius: 50%;
}
.amount-landing input[type="radio"]:checked + label span {
background: #101B27;
}
<div class="content ">
<div class="form-group">
<div class="row amount-landing gray-line">
<div class="col-xs-2 col-xs-offset-1"><input type="radio"><label for="amount1"><span></span></label></div>
<div class="col-xs-2"><input type="radio"><label for="amount2"><span></span></label></div>
<div class="col-xs-2"><input type="radio"><label for="amount3"><span></span></label></div>
<div class="col-xs-2"><input type="radio"><label for="amount4"><span></span></label></div>
<div class="col-xs-2"><input type="radio"><label for="amount5"><span></span></label></div>
</div>
<!-- This shows radio buttons -->
<div class="row text-center" style="font-size: 14px;color: #FFFFFF;line-height: 14px;">
<div class="col-xs-1"></div>
<div class="col-xs-2">0$</div>
<div class="col-xs-2">1$<br>-<br>1000$</div>
<div class="col-xs-2">1001$<br>-<br>2001$</div>
<div class="col-xs-2">2001$<br>-<br>3000$</div>
<div class="col-xs-2">More than<br>3000$</div>
<div class="col-xs-1"></div>
</div>
<!-- This shows numbers -->
</div>
</div>
<link href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap.min.css" rel="stylesheet" integrity="sha384-BVYiiSIFeK1dGmJRAkycuHAHRg32OmUcww7on3RYdg4Va+PmSTsz/K68vbdEjh4u" crossorigin="anonymous">
So, the code is basically some cols with the radio buttons and labels for making a custom radio button, then I applied a gray line (is an img) to all cols in the first row for making possible showing the background line but this method covers all the column background; then in another row put the amount labels, this also have responsive issues when you shrink the screen the amount labels gets too close each other.
Help would appreciated to light my path, thank you.
Use id and name attributes for your input type="radio". Radio buttons with the same name can only be used as one "group." No need to use 'span' inside 'labels'.
White background line is styled using CSS pseudo element ":after". No need to use background images. In order to avoid the background line expanding beyond the last radio button, made "content" property to none for the last div. This is achieved using CSS pseudoclass ":last-of-type".
.content {background-color: #42d5b9; padding: 50px;}
.amount-landing {text-align: center;}
.amount-landing label {color: #FFFFFF;}
.amount-landing .amount-col {
position: relative;}
.amount-landing .amount-col:after {
content: "";
position:absolute;
width: 100%;
height: 2px;
background-color: #fff;
top: 50%;
}
.amount-landing .amount-col:last-of-type:after {
content: none;
}
.amount-landing input[type="radio"] {
display:none;
}
.amount-landing input[type="radio"] + label {
display:inline-block;
width: 20px;
height:20px;
margin:0px 0px 0 0;
vertical-align:middle;
background: #FFFFFF;
cursor:pointer;
border-radius: 50%;
}
.amount-landing input[type="radio"]:checked + label {
background: #101B27;
}
<div class="content ">
<div class="form-group">
<div class="row amount-landing gray-line">
<div class="col-xs-2 col-xs-offset-1 amount-col"><input type="radio" id="amount1" name="amount"><label for="amount1"></label></div>
<div class="col-xs-2 amount-col"><input type="radio" id="amount2" name="amount"><label for="amount2"></label></div>
<div class="col-xs-2 amount-col"><input type="radio" id="amount3" name="amount"><label for="amount3"></label></div>
<div class="col-xs-2 amount-col"><input type="radio" id="amount4" name="amount"><label for="amount4"></label></div>
<div class="col-xs-2 amount-col"><input type="radio" id="amount5" name="amount"><label for="amount5"></label></div>
</div>
<!-- This shows radio buttons -->
<div class="row text-center" style="font-size: 13px;color: #FFFFFF;line-height: 15px;">
<div class="col-xs-1"></div>
<div class="col-xs-2">0$</div>
<div class="col-xs-2">1$-1000$</div>
<div class="col-xs-2">1001$-2001$</div>
<div class="col-xs-2">2001$-3000$</div>
<div class="col-xs-2">More than 3000$</div>
<div class="col-xs-1"></div>
</div>
<!-- This shows numbers -->
</div>
</div>
<link href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap.min.css" rel="stylesheet" integrity="sha384-BVYiiSIFeK1dGmJRAkycuHAHRg32OmUcww7on3RYdg4Va+PmSTsz/K68vbdEjh4u" crossorigin="anonymous">

:active and :focus on anchor is not working for IE and Mozilla

In the below HTML code I am trying to achieve color change on current active anchor means once any tab is clicked it should show color(#ffd96b) as its background, it is working fine for Chrome but not working for IE and Mozilla. Not getting why it is happening may be I have missed something, Any help is much appreciated.
.tileMargin {
margin: 5%;
}
.deviceName {
width: 60%;
float: left;
padding: 5px;
border-radius: 5px 0px 0px 5px;
border: 1px solid #ccc;
background-color: #f2f2f2;
font-size: 0.75em;
}
.deviceCount {
width: 40%;
float: left;
background-color: #f2f2f2;
border-radius: 5px;
border: 1px solid #ccc;
text-align: center;
margin-left: -3px;
}
.deviceCount >div {
width: 33.33%;
float: left;
border-left: 1px solid #ccc;
}
.deviceCount input,
button {
width: 100%;
float: left;
padding: 3px 0px;
background-color: #f2f2f2;
border: none;
text-align: center;
appearance: button;
border-radius: 5px;
}
.devicesSmall a:hover div,
.devicesSmall a:hover input,
.devicesSmall a:hover button,
.devicesSmall a:active div,
.devicesSmall a:active input,
.devicesSmall a:active button,
.devicesSmall a:focus div,
.devicesSmall a:focus input,
.devicesSmall a:focus button {
background-color: #ffd96b !important;
}
<!Doctype HTML>
<html lang="en">
<head>
<Title>asd sada asfa</Title>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1">
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script>
<link href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap.min.css" rel="stylesheet" type="text/css" />
<script src="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/js/bootstrap.min.js"></script>
</head>
<body>
<div class="container-fluid">
<div class="row">
<div class="tileMargin">
<div class="devicesSmall col-lg-3 col-md-3 col-sm-6 col-xs-6 ">
<a href="#">
<div class="deviceName"><span>Mobile</span>
</div>
<div class="deviceCount">
<div>
<button onclick="addProduct('mobile');">+</button>
</div>
<div>
<input id="mobile" type="text" value="1" disabled>
</div>
<div>
<button onclick="removeProduct('mobile');">-</button>
</div>
</div>
</a>
</div>
<div class="devicesSmall col-lg-3 col-md-3 col-sm-6 col-xs-6">
<a href="#">
<div class="deviceName"><span>Landline</span>
</div>
<div class="deviceCount">
<div>
<button onclick="addProduct('landline');">+</button>
</div>
<div>
<input id="landline" type="text" value="1" disabled>
</div>
<div>
<button onclick="removeProduct('landline');">-</button>
</div>
</div>
</a>
</div>
<div class="devicesSmall col-lg-3 col-md-3 col-sm-6 col-xs-6">
<a href="#">
<div class="deviceName"><span>Internet</span>
</div>
<div class="deviceCount">
<div>
<button onclick="addProduct('internet');">+</button>
</div>
<div>
<input id="internet" type="text" value="0" disabled>
</div>
<div>
<button onclick="removeProduct('internet');">-</button>
</div>
</div>
</a>
</div>
<div class="devicesSmall col-lg-3 col-md-3 col-sm-6 col-xs-6">
<a href="#">
<div class="deviceName"><span>IPTV</span>
</div>
<div class="deviceCount">
<div>
<button onclick="addProduct('Iptv');">+</button>
</div>
<div>
<input id="Iptv" type="text" value="1" disabled>
</div>
<div>
<button onclick="removeProduct('Iptv');">-</button>
</div>
</div>
</a>
</div>
<div class="clearfix"></div>
</div>
</div>
</div>
</body>
</html>
It is not that it isnt working in FF or IE, :active is applied at the moment when you click the element and DOES NOT preserve it. The styling is removed once you release the click.
Also after you click the link Chrome keeps the focus on the link whereas FF and IE does not. That is why the :focus styling is removed after you click it.
To make a link active, add a class active in CSS and add/remove the classes according to which link was clicked using JS.
First of all, Thanks to you all for looking into this issue...
I have found the issue in my code that was creating problem and causing :active and :focus not work as expected. Actually I had placed the form element like input and button under anchor tag, which is not correct implementation according to w3c standards.
Now I have removed all the button and input from inside that "a" tag and its working fine now.

Center input horizontally in div

I know this has been answered 100 times, but none of the existing solutions seem to work for me.
I want to center an input field horizontally in a div. Why is horizontal centering such a pain?!?!? The parent div may change in size based on screen size, so margin percentages don't work.
HTML
<div class="select" id="avatar">
<h4>Please enter your name.</h4>
<!-- Object i want to center-->
<div class="input-group">
<input type="text" class="form-control text-center" id="playerName">
</div>
<h4>And Select Your Ship</h4>
<img class="avatars" id="ship1" src="images/spaceship1.png">
<img class="avatars" id="ship2" src="images/spaceship2.png">
<img class="avatars" id="ship3" src="images/spaceship3.png">
<img class="avatars" id="ship4" src="images/spaceship4.png">
<button class="btn" id="submitPlayer">Submit</button>
</div>
parents CSS
.select {
background-color: white;
z-index: 200;
padding: 0px 15px 0px 15px;
text-align: center;
font-family: 'Krona One', sans-serif;
border: medium dashed green;
margin-left: 25%;
margin-right: 25%;
}
I also want to center this one, and I assume it will be the same solution, but it has no parent, besides body.
<div class="input-group">
<input class="text-center" type="text" id="word">
</div>
Why not use Bootstrap's center-block class..
<div class="input-group center-block">
<input class="center-block" type="text" id="word">
</div>
http://www.bootply.com/sTboTk5CvU
inputs and button are like img, you can display them as block and use margin:auto; so they stand alone and in the middle without using 100% of the width/space avalaible :
.select {
background-color: white;
z-index: 200;
padding: 0px 15px 0px 15px;
text-align: center;
font-family: 'Krona One', sans-serif;
border: medium dashed green;
margin-left: 25%;
margin-right: 25%;
}
button.btn#submitPlayer {
display: block;
margin: auto;
}
<link href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap.min.css" rel="stylesheet" />
<div class="select" id="avatar">
<h4>Please enter your name.</h4>
<!-- Object i want to center-->
<div class="input-group">
<input type="text" class="form-control text-center" id="playerName">
</div>
<h4>And Select Your Ship</h4>
<img class="avatars" id="ship1" src="images/spaceship1.png">
<img class="avatars" id="ship2" src="images/spaceship2.png">
<img class="avatars" id="ship3" src="images/spaceship3.png">
<img class="avatars" id="ship4" src="images/spaceship4.png">
<button class="btn" id="submitPlayer">Submit</button>
</div>
and you may do the same with input :
.input-group,
input#word.text-center{
display: block;
margin: auto;
}
<link href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap.min.css" rel="stylesheet" />
<div class="input-group">
<input class="text-center" type="text" id="word">
</div>