Prevent parent CSS while focus on child button - css

I've a <div> wrapped within <a>. a:active has css to transform the element but I don't want that behaviour (transform) to be there while I focus on bx--overflow-menu child. I am using NextJS with styled-jsx and SaSS. Below is my code :
<a class="singleTile" data-cta-type="unimplemented" href="test">
<div class="bx--row">
<div class="bx--overflow-menu" role="button" aria-haspopup="true" aria-expanded="false" aria-label="Menu" tabindex="0">
<svg focusable="false" aria-label="open and close list of options" role="img" class="bx--overflow-menu__icon">
<circle cx="8" cy="3" r="1"></circle>
<circle cx="8" cy="8" r="1"></circle>
<circle cx="8" cy="13" r="1"></circle>
<title>open and close list of options</title>
</svg>
</div>
<div class="bx--col">
<p class="name-212">cougar</p>
<p class="name-213">Version:<span class="" style="display: inline;">test.1</span></p>
</div>
</div>
</a>
The styles:
<style>
.singleTile {
flex: none;
width: 100%;
border: 1px solid #e0e0e0;
display: block;
padding: 1rem;
transition: all 150ms cubic-bezier(0.2, 0, 0.38, 0.9);
background-color: #ffffff;
}
a.singleTile:hover {
border-color: red;
}
a.singleTile:active {
transform: scale(.994);
}
.bx--overflow-menu{
top: 0;
right: .25rem;
position: absolute;
}
</style>
I have some idea that it can't be done with CSS only and I am also not allowed to use jQuery.
Any other suggestions will be helpful.

There are no parent selectors in css right now. It could be possible to implement this on next css4.
.singleTile:has(> bx--overflow-menu:active) { /* styles to apply to the singleTile tag */ }

Related

Two child components in parent div (flex row) always at the same height in angular 10

disclaimer: sorry if my answer is somwhere in stackoverflow... Did not find and starting being a little frustrating...
I'm working with Angular 10 and in my app.component.html, have this snippet :
<div class="chats">
<app-friend-chat *ngFor="let friend of friends" [inputFriend]="friend" (close)="closeChat($event)">
</app-friend-chat>
<app-friend-list (friend)="openChat($event)"></app-friend-list>
</div>
The component app-friend-chat is dynamic and at the started time of the site, there is no instances of it so only app-friend-list is display.
Here is the css of app.component.css :
app-friend-chat{
position: relative;
margin: 0 !important;
width: 50vh;
}
.chats{
position: absolute;
bottom: 0;
right: 5px;
z-index: 9999;
display: flex;
flex-direction: row;
}
The thing is app-friend-list's height is moving up to creation of a new app-chat-friend's instance.
When closing all app-chat-friend's instances, app-friend-list get height back to its first value.
I want my app-friend-list keep its height.
Here is app-friench-chat'html :
<div *ngIf="friend">
<div class="chatHead" fxLayout="row" fxLayoutGap="5px">
<p class="friend">{{ friend.name }}</p>
<span fxFlex="auto" (click)="minimize()"></span>
<p class="close" (click)="closeChat(friend.name)">X</p>
</div>
<div *ngIf="!mini">
<div id="messages-box">
<div *ngFor="let message of messages" class="message">
<div [ngClass]="classForParagraphe(message)" class="paragraphe"
[innerHTML]="sanitizer.bypassSecurityTrustHtml(message.message)">
</div>
<div *ngIf="user.name === message.user" class="trash">
<span class="far fa-trash-alt" (click)="deleteMessage(message)"></span>
</div>
</div>
</div>
<emoji-mart class="emoji-mart" *ngIf="isEmojiPickerVisible" (emojiSelect)="addEmoji($event)"></emoji-mart>
<div fxLayout="row" fxLayoutGap="15px">
<div class="container">
<input [(ngModel)]="message" type="text" #input (keyup)="enter($event)" />
<button (click)="isEmojiPickerVisible = !isEmojiPickerVisible;">😀</button>
</div>
<button (click)="sendMessage()">
<svg width="20px" height="20px" viewBox="0 0 24 24">
<path
d="M16.6915026,12.4744748 L3.50612381,13.2599618 C3.19218622,13.2599618 3.03521743,13.4170592 3.03521743,13.5741566 L1.15159189,20.0151496 C0.8376543,20.8006365 0.99,21.89 1.77946707,22.52 C2.41,22.99 3.50612381,23.1 4.13399899,22.8429026 L21.714504,14.0454487 C22.6563168,13.5741566 23.1272231,12.6315722 22.9702544,11.6889879 C22.8132856,11.0605983 22.3423792,10.4322088 21.714504,10.118014 L4.13399899,1.16346272 C3.34915502,0.9 2.40734225,1.00636533 1.77946707,1.4776575 C0.994623095,2.10604706 0.8376543,3.0486314 1.15159189,3.99121575 L3.03521743,10.4322088 C3.03521743,10.5893061 3.34915502,10.7464035 3.50612381,10.7464035 L16.6915026,11.5318905 C16.6915026,11.5318905 17.1624089,11.5318905 17.1624089,12.0031827 C17.1624089,12.4744748 16.6915026,12.4744748 16.6915026,12.4744748 Z">
</path>
</svg>
</button>
</div>
</div>
</div>
And css :
.chatHead {
background: rgb(210, 206, 206);
border-radius: 10px;
height: 5vh;
}
#messages-box {
height: 45vh;
background-color: white;
padding-left: 0;
overflow-y: scroll;
}
app-friend-list'html:
<div *ngIf="user && user.name !== undefined">
<h6 (click)="showList()">Discussions</h6>
<div class="list" *ngIf="show">
<ul *ngFor="let ami of user.amis">
<li (click)="addChat(ami)">{{ ami }}</li>
</ul>
</div>
</div>
app-friend-list'css:
h6{
padding: 10px;
border: solid 1px black;
height: 5.5vh;
}
ul {
padding-right: 20px;
}
li {
list-style: none;
cursor: pointer;
}
I give you only relevant code (according to me).
The other probleme I can't get ride of is that when clicking on chatHead of app-friend-chat for minimize, the component get same size of app-friend-list and so let empty space at the bottom which is very dirty (should get only size of head part)
Feel free to ask me any code I forgot to give you.

Put transparent navbar on top of jumbotron - Bootstrap

I'm trying to make a landing page with a big jumbotron at the top and a transparent navbar placed on top of it, like this: https://stripe.com/en-gb-dk. The jumbotron just has a coloured background (i.e. no background image). I have tried fixed-top, which achieves the desired effect; however, I'm not interested in the navbar being fixed to the top (i.e. follow the page on scroll) - I'm just interested in the transparent navbar being on top of the jumbotron. Does anyone know how I can achieve this using bootstrap? Thanks!
Below is my code (I use Bootstrap in conjunction with React)
Navbar:
<nav className={`navbar navbar-expand-md navbar-light bg-transparent`}>
<div className="container-fluid">
<a className="navbar-brand">
<img src="/images/logo.png" alt="" className="img-fluid" />
</a>
<button
onClick={() => setShowMenu(!showMenu)}
className="navbar-toggler"
type="button"
data-toggle="collapse"
data-target="#navbarNavAltMarkup"
aria-controls="navbarNavAltMarkup"
aria-expanded="false"
aria-label="Toggle navigation"
>
<span className="navbar-toggler-icon"></span>
</button>
<div className={`collapse navbar-collapse ${showMenu ? "show" : ""}`}>
<div className="navbar-nav mx-auto">
<li className="nav-item active">
<a className="nav-link" href="#">
Link 1
</a>
</li>
<li className="nav-item active">
<a className="nav-link" href="#">
Link 2
</a>
</li>
<li className="nav-item active">
<a className="nav-link" href="#">
Link 3
</a>
</li>
</div>
<div className="nav navbar-nav nav-right">
<li className="nav-item active">
<a className="nav-link" href="#">
Link 4
</a>
</li>
</div>
</div>
</div>
<style jsx>
{`
.navbar .navbar-collapse {
text-align: center;
}
#media (min-width: 992px) {
.nav-right {
float: right;
}
}
`}
</style>
</nav>
Jumbotron:
<section>
<div className="main-jumbotron">
<h1>Let us help you find your next expert</h1>
<h4>
At beautykonect, we have the best experts ready to help you
</h4>
<div className="text-center mt-5">
<button className="btn btn-primary btn-lg outline">Get started</button>
</div>
<svg
xmlns="http://www.w3.org/2000/svg"
viewBox="0 0 100 100"
preserveAspectRatio="none"
>
<polygon fill="white" points="0,100 100,0 100,100" />
</svg>
</div>
<style jsx>
{`
svg {
position: absolute;
bottom: 0;
width: 100%;
height: 10vw;
}
.main-jumbotron {
position: relative;
height: 90vh;
min-height: 300px;
background: rgb(255, 216, 223);
background: linear-gradient(
90deg,
rgba(255, 216, 223, 1) 0%,
rgba(252, 189, 201, 1) 53%,
rgba(255, 134, 157, 1) 100%
);
}
.main-jumbotron h1 {
padding-top: 125px;
text-align: center;
color: white;
font-weight: 700;
}
.main-jumbotron h4 {
color: white;
margin-top: 25px;
font-weight: 600;
text-align: center;
}
.btn.outline {
background: none;
padding: 12px 22px;
}
.btn-primary.outline {
border: 2px solid #fff;
color: #fff;
}
.btn-primary.outline:hover,
.btn-primary.outline:focus,
.btn-primary.outline:active,
.btn-primary.outline.active,
.open > .dropdown-toggle.btn-primary {
color: rgba(252, 189, 201, 1);
border-color: #fff;
background-color: #fff;
}
.btn-primary.outline:active,
.btn-primary.outline.active {
border-color: #007299;
color: #007299;
box-shadow: none;
}
`}
</style>
<section>
This is what it looks like now
What I want to do then is to make the navbar transparent and push the banner/jumbotron up, such that there is no white section at the top of the page
Edit: added code and photo
Bootstrap provides a utility class position-absolute which will give the desired result but it does not have classes to handle specific positioning properties such as top.
This solution follows the same approach as the example, apply this new style rule in the inline style for the navbar:
.navbar {
position: absolute; // could use 'position-absolute' on navbar instead
top: 0;
left: 0;
width: 100%; // could also use class 'w-100' on navbar instead
}

Multiline underlined button

I am having issues with underlining button text using box-shadow and wrapping it on multiple lines. It should be solved using just CSS.
Needs to use the following HTML (can't add HTML tags, special characters etc.):
<button class="button">
<span class="button__inner">
<span class="button__text">
Button with very very very long example text
</span>
<svg class="button__icon" width="24" height="24" viewBox="0 0 24 24">
<path d="M4,11V13H16L10.5,18.5L11.92,19.92L19.84,12L11.92,4.08L10.5,5.5L16,11H4Z" />
</svg>
</span>
</button>
Visually it should look like this!
Requirements:
Use box-shadow to underline text on multiple lines.
Do not add additional HTML (needs to use HTML structure provided above).
.button__inner has to be display: flex or inline-flex.
The icon needs to be aligned right (in its own column), vertically centered and not have underline.
.button {
background: none;
border: none;
font-size: 12px;
cursor: pointer;
}
.button:focus {
outline: none;
}
.button__inner {
display: flex;
align-items: center;
justify-content: flex-start;
text-align: left;
}
.button__text {
box-shadow: inset 0 -1px currentColor;
}
.button:hover .button__text {
box-shadow: none;
}
.button__icon {
width: 1em;
height: 1em;
}
p {
font-size: 14px;
line-height: 1.2em;
}
<div style="max-width: 200px">
<p>
Following button using correct HTML, however box-shadow does not underline correctly on multiple lines. The icon needs to be on the right in its own column so therefore adding display: inline; to .button__inner is not an option.
</p>
<button class="button">
<span class="button__inner">
<span class="button__text">
Button with very very very long example text
</span>
<svg class="button__icon" width="24" height="24" viewBox="0 0 24 24">
<path d="M4,11V13H16L10.5,18.5L11.92,19.92L19.84,12L11.92,4.08L10.5,5.5L16,11H4Z" />
</svg>
</span>
</button>
<p>
Below is the visually desired result, however it uses an additional span element. How to achieve this using just CSS and without altering the HTML?
</p>
<button class="button">
<span class="button__inner">
<span>
<span class="button__text">
Button with very very very long example text
</span>
</span>
<svg class="button__icon" width="24" height="24" viewBox="0 0 24 24">
<path d="M4,11V13H16L10.5,18.5L11.92,19.92L19.84,12L11.92,4.08L10.5,5.5L16,11H4Z" />
</svg>
</span>
</button>
</div>
Is this even possible using just CSS?
Does it work in your case to use text-decoration: underline instead of box-shadow? like this example: https://codepen.io/annaazzam/pen/PoZEJwX

Range input refuses to change background color and height

So I'm working on a website for a radio station and have encountered an issue. The range input we use for volume literally refuses to change its background color and height. I'm using SASS (which makes it a scss file type) for the purposes of this project.
I've done some research and have tried a few things the Internet recommended, but unfortunately, none have worked. I have tried using background, background-color and even color fields to try and fix my issue. I have made sure to overwrite everything that might be stopping me from doing so by setting the -webkit-appearance to none.
This is the content of the slider and its parent elements in my hbs file:
<div class="rootplayer">
<div>
<img class="picture" alt='Artist art' src="{{songart}}" width="170px">
<div class="playerinfo">
<p>On air: {{dj}}</p>
<hr>
<p>Up next: AJS Show</p>
<hr>
<p>Currently playing: {{songTitle}}</p>
<hr>
<p>Current Listeners: {{currentListeners}}</p>
</div>
<audio controls="" id="player">
<source src="http://radio.nowhits.uk:8000/radio.mp3" type="audio/mpeg">
<p>Your browser does not support the audio element.</p>
</audio>
</div>
<div class="playercontrols">
<i class="fas fa-play" onclick="play()" id="play"></i>
<i class="fas fa-pause" onclick="pause()" id="pause"></i>
<input type="range" min="0" max="1" value="0.5" step="0.01" class="slider" id="volume">
<script src="scripts/volume.js"></script>
<script src="scripts/playpause.js"></script>
</div>
</div>
And this is the content of the slider object in my scss file:
.slider {
-webkit-appearance: none;
height: 1px;
width: 65%;
background-color: red;
outline: none;
opacity: 0.7;
-webkit-transition: .2s;
transition: opacity .2s;
cursor: pointer;
}
.slider::-webkit-slider-thumb {
-webkit-appearance: none;
appearance: none;
width: 12px;
height: 12px;
background: #000;
border-radius: 50%;
}
.slider::-moz-range-thumb {
width: 12px;
height: 12px;
background: #000;
cursor: pointer;
border-radius: 50%;
}
Obviously, the expected output should be a red background and a height of 1px (should be a pretty thin line), but instead, I get this.
Try to add this :
.slider::-webkit-slider-runnable-track {
background: red;
}
.slider::-moz-range-track {
background: red;
}
.slider::-ms-track {
background: red;
}
Look at this site for more customizations : http://danielstern.ca/range.css

CSS <h> Margin help?

I have a margin used to space some headings down away from an image, but despite this method working on other pages, it does not in this instance.
I know there are plenty of alternative solutions, but am curious as to what is wrong with this one. Can anyone help?
<div class="column" style="width: 237px">
<img src="img.jpg" alt="" title="img" width="237" height="300" class="alignnone size-full wp-image-84" />
<h1 style="margin-top: 40px">VAL</h1>
<span class="detailhead">Heading 1</span> <span class="detail">Detail 1</span><br />
<span class="detailhead">Heading 2</span> <span class="detail">Detail 2</span>
</div>
These are all the additional class declarations:
The image class has no associated style (class was inserted by Wordpress).
h1 {
font-size: 17px;
}
span.detailhead{
font-size: 13px;
color:#000000;
}
span.detail {
position: relative;
top: 1.5px;
font-size: 14px;
color:#000000;
}
.column {
display: block;
float: left;
}
Here is the offending style i overlooked:
img {
display: block;
float:left;
margin-right:10px;
margin-bottom:10px;
border-style: solid;
border-width: 1px;
border-color: #ffffff;
z-index: 2;
}
A more specific selector fixed the issue.
Thanks to all for helping me with this seriously schoolboy error!
Could you try adding a style="display:block" to the img tag?
If your using chrome or safari for testing: use the element inspector to check wether your inline setting is not overruled by an !important; declaration in one of the classes.
Edit: To quickly test this you can also add " !important;" to your inline css.

Resources