angular: Jumping scrollbar in scroll panel of editText - css

My app has collapsible panel. It contains scroll panel with EditText (is generated by *ngFor). I was trying selve this by adding:
html {
overflow-y: scroll; /*not working*/
}
and another sollutions which i found in this article, but it is not working.
Im also using AutosizeModule to resize EditText (ngx-autosize).
This problem looks like that:
Component:
#Component({/* typical content */})
export class AnswerDialogComponent implements OnInit {
constructor() {
}
answerText: string[] = [/*string values */'];
ngOnInit() {
}
trackByIndex(index: number): any {
return index;
}
}
MyHtml:
<div id="answerDialog">
<h3>Answers:</h3>
<hr>
<nav>
<ul>
<li *ngFor="let i of answerText; let index =index; trackBy: trackByIndex;">
<textarea autosize name="Text" class="input" [(ngModel)]="answerText[index]" ></textarea>
</li>
</ul>
</nav>
</div>
my CSS:
#answerDialog {
display: block;
margin-top: -50px;
width: 300px;
border: 1px solid #8BC3A3;
border-radius: 10px 0 0 10px;
background: #fefefe;
max-height: 595px;
height: auto;
position: fixed;
right: 510px;
z-index: 1;
padding-bottom: 10px;
border-right: 0;
}
hr {
margin-top: 5px;
}
h3 {
font-size: 20px;
text-align: center;
margin-bottom: 15px;
font-family: Helvetica, Arial, sans-serif;
}
.input {
border-radius: 5px;
background: #f8f8f8;
border: 1px solid rgba(0, 0, 0, 0.075);
color: #727272;
width: 90%;
height: auto;
vertical-align: middle;
resize: none;
outline: none;
margin-bottom: 5px;
margin-top: 5px;
}
.input:hover {
border: 1px solid #8BC3A3;
}
.input:focus {
outline: none;
border: 1px solid #8BC3A3;
}
nav ul {
overflow-y: auto;
max-height: 505px;
height: auto;
}
html {
overflow-y: scroll; /*not working*/
}
::-webkit-scrollbar {
width: 10px;
}
::-webkit-scrollbar-track {
background: #f1f1f1;
border-radius: 8px;
}
::-webkit-scrollbar-thumb {
background: #8BC3A3;
border-radius: 8px;
}
::-webkit-scrollbar-thumb:hover {
background: #555;
}

Related

i dont understand why this background dont get painted

I have two problems. The first thing is that when I hover over one thing (https://prnt.sc/s9etq3 (the mouse isnt visible because of the screenshot but it is on the object)) I only get an outline and not the full background. The second thing is that I'm too stupid to scale the search box right. I want that it's 10% away from the sides (left and right). The code for the hovering is inside div.gallery:hover
#import url('https://fonts.googleapis.com/css?family=Roboto');
*{
margin: 0;
background: #222;
padding: 0;
font-family: 'Roboto', sans-serif;
}
.search_box{
position: relative;
left: 0%;
}
.search_box input[type="text"]{
width: 100%;
padding: 20px;
padding-right: 60px;
box-sizing: border-box;
background: rgba(0,0,0,0.3);
border: 2px solid #fff;
border-radius: 10px;
font-size: 18px;
color: #fff;
outline: none;
}
.fa-search{
position: absolute;
top: 50%;
transform: translateY(-50%);
right: 25px;
color: #fff;
font-size: 25px;
}
::-webkit-input-placeholder {
color: #fff;
}
::-moz-placeholder {
color: #fff;
}
:-ms-input-placeholder {
color: #fff;
}
#media screen and (max-width: 425px){
.search_box{
width: 95%;
}
}
div.gallery {
margin: 5px;
border: 1px solid #222;
float: left;
width: 180px;
}
div.gallery:hover {
border: 1px solid #404040;
background: #404040;
}
div.gallery img {
width: 100%;
height: auto;
}
div.desc {
padding: 15px;
text-align: center;
}
.container
{
max-width: 1200px;
margin: 0 auto;
display: flex;
flex-wrap: wrap;
}
.container div
{
margin: 10px;
}
.container div label
{
cursor: pointer;
}
.container div label input[type="checkbox"]
{
display: none;
}
.container div label span
{
position: relative;
display: inline-block;
background: #424242;
padding: 15px 30px;
color: #555;
text-shadow: 0 1px 4px rgba(0,0,0,.5);
border-radius: 20px;
font-size: 20px;
transition: 0.5s;
user-select: none;
overflow: hidden;
}
.container div label span:before
{
content: '';
position: absolute;
top: 0;
left: 0;
width: 100%;
height: 50%;
}
.container div label input[type="checkbox"]:checked ~ span
{
width: 100%;
padding: 20px;
padding-right: 60px;
box-sizing: border-box;
background: rgba(0,0,0,0.3);
border: 2px solid #fff;
border-radius: 10px;
font-size: 18px;
color: #fff;
outline: none;
}
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>Search</title>
<link rel="stylesheet" href="css/style.css">
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.3/jquery.min.js"></script>
<div class="wrapper">
<div class="search_box">
<input type="text" name="box" id="search_text" placeholder="Search by Customer Details" class="form-control" />
</div>
</div>
</head>
<body>
<div id="result"></div>
<div style="clear:both"></div>
</body>
</html>
<script>
$(document).ready(function(){
load_data();
function load_data(query)
{
$.ajax({
url:"fetch.php",
method:"post",
data:{query:query},
success:function(data)
{
$('#result').html(data);
}
});
}
$('#search_text').keyup(function(){
var search = $(this).val();
if(search != '')
{
load_data(search);
}
else
{
load_data();
}
});
});
</script>
ยดยดยด

Algolia autocomplete not visible with material input field

I am using material web components in my project, as well as an algolia autocomplete.js. I have made a search input field where I would like to show the results in an autocomplete dropdown menu. This is the html:
<form action="/search" method="get">
<div class="mdc-text-field mdc-text-field--box mdc-text-field--with-leading-icon">
<i class="material-icons mdc-text-field__icon" tabindex="0">search</i>
<input name="q"
type="text"
class="mdc-text-field__input search-input-js aa-input-search"
placeholder="Search for players and videos ..."
aria-label="Full-Width Text Field">
</div>
</form>
And this is the css:
.algolia-autocomplete {
display: flex!important;
flex: auto!important;
height: 100%;
}
.aa-dropdown-menu {
position: relative;
top: -6px;
border-radius: 3px;
margin: 6px 0 0;
padding: 0;
text-align: left;
height: auto;
position: relative;
background: $white;
border: 1px solid #ccc;
width: 100%;
left: 0 !important;
box-shadow: 0 1px 0 0 rgba(0, 0, 0, 0.2), 0 2px 3px 0 rgba(0, 0, 0, 0.1);
}
.aa-dropdown-menu:before {
position: absolute;
content: '';
width: 14px;
height: 14px;
background: #fff;
z-index: 0;
top: -7px;
border-top: 1px solid #D9D9D9;
border-right: 1px solid #D9D9D9;
transform: rotate(-45deg);
border-radius: 2px;
z-index: 999;
display: block;
left: 24px;
}
.aa-dropdown-menu .aa-suggestions {
position: relative;
z-index: 1000;
}
.aa-dropdown-menu [class^="aa-dataset-"] {
position: relative;
border: 0;
border-radius: 3px;
overflow: auto;
padding: 8px 8px 8px;
color: #3c3e42;
font-weight: 500;
}
.aa-dropdown-menu * {
box-sizing: border-box;
}
.aa-suggestion {
padding: 0 4px 0;
display: block;
width: 100%;
height: 38px;
clear: both;
}
.aa-suggestion span {
white-space: nowrap !important;
text-overflow: ellipsis;
overflow: hidden;
display: block;
float: left;
line-height: 1em;
width: calc(100% - 30px);
}
.aa-suggestion.aa-cursor {
background-color: transparent;
}
.aa-suggestion em {
color: #00bcd4;
font-weight: 700;
}
.aa-suggestion img {
float: left;
height: 44px;
width: 44px;
margin-right: 6px;
}
.aa-suggestion a {
color: #3c3e42;
}
.aa-suggestions-category {
font-weight: 700;
color: #3c3e42;
border-bottom: 1px solid rgba(102, 105, 105, 0.17);
}
.powered-by-algolia {
padding-left: 15px;
border-top: 1px solid rgba(102, 105, 105, 0.17);
display: flex;
align-items: center;
height: 30px;
}
.aa-input-container {
display: inline-block;
position: relative; }
.aa-input-search {
width: 100%;
height: 30px;
padding: 12px 28px 12px 12px;
box-sizing: border-box;
-webkit-appearance: none;
-moz-appearance: none;
appearance: none; }
.aa-input-search::-webkit-search-decoration, .aa-input-search::-webkit-search-cancel-button, .aa-input-search::-webkit-search-results-button, .aa-input-search::-webkit-search-results-decoration {
display: none;
}
.media {
margin: 10px 0;
}
.media-body {
p {
margin: 0;
}
}
The problem I have is that the dropdown menu is not visible with the mdc-text-field--box if I am not using the box field and I am instead using the normal field then the dropdown menu is visible. How can I fix this so that the dropdown menu is also visible with the mdc-text-field--box?
You should update the CSS in order to override the overflow on .mdc-text-field--box and update the pseudo elements.
.mdc-text-field--box {
overflow: visible;
}
.mdc-text-field--box:after,
.mdc-text-field--box:before {
top: 0;
left: 0;
width: 100%;
height: 100%;
}
You can find an example on the jsFiddle also.

Aligning input box inside panel body with the use of css grid

I have created a login using css grid layout. I want to implement a form input box inside the panel body. However, the input box not respecting inside the panel body. The input box was overflow outside the panel body. For some reason, the code is working with regular css. I just want to implement css grid and i'm not sure about to go about this.
Thanks for any help.
Here is the fiddle.
<pre>
https://jsfiddle.net/80fc325h/
Just use *{box-sizing: border-box} It will be updated. Hope it is helpful to you. Kindly check the snippet. As CSS3 box-sizing property allows us to include the padding and border in an element's total width and height.
body {
margin: 0;
font-size: 13px;
color: #222;
background-color: #f5f5f5;
}
* {
box-sizing:border-box;
}
.text-right{
text-align: right;
}
/*--------------------------------------------------------------
style:
--------------------------------------------------------------*/
.login-wrapper{
display:grid;
grid-template-columns:1fr;
width: 50%;
margin: 0 auto;
}
.content{
display:grid;
grid-template-columns:1fr;
border:1px solid red;
}
.panel {
background-color: #fff;
border: 1px solid #dbd9d9;
border-radius: 4px;
-webkit-box-shadow: 0 1px 1px rgba(0, 0, 0, .05);
box-shadow: 0 1px 1px rgba(0, 0, 0, .05);
}
.panel-body {
padding: 15px;
}
.panel-heading {
text-align: center;
padding: 5px 10px;
border-top-left-radius: 3px;
border-top-right-radius: 3px;
}
.panel-title {
margin-top: 0;
margin-bottom: 0;
color: inherit;
}
.panel-footer {
padding: 10px 15px;
background-color: #fff;
border-top: 1px solid #dbd9d9;
}
/*--------------------------------------------------------------
Form:
--------------------------------------------------------------*/
.form-control {
display: block;
width: 100%;
height: 34px;
padding: 6px 12px;
line-height: 1.42857143;
color: #555;
background-color: #fff;
background-image: none;
border: 1px solid #ccc;
border-radius: 4px;
}
.form-control:focus {
outline: 0;
}
.form-control::-moz-placeholder {
color: #999;
opacity: 1;
}
.form-control:-ms-input-placeholder {
color: #999;
}
.form-control::-webkit-input-placeholder {
color: #999;
}
.form-control::-ms-expand {
background-color: transparent;
border: 0;
}
.input-sm {
height: 29px;
padding: 5px 10px;
font-size: 12px;
line-height: 1.5;
border-radius: 3px;
}
.has-feedback {
position: relative;
}
.has-feedback .form-control {
padding-right: 42.5px;
}
.form-control-feedback {
position: absolute;
top: 0;
right: 0;
z-index: 2;
display: block;
width: 34px;
height: 34px;
line-height: 34px;
text-align: center;
pointer-events: none;
}
.has-error .help-block,
.has-error .control-label,
.has-error .radio,
.has-error .checkbox,
.has-error .radio-inline,
.has-error .checkbox-inline,
.has-error.radio label,
.has-error.checkbox label,
.has-error.radio-inline label,
.has-error.checkbox-inline label {
color: #f44336;
}
.has-error .form-control {
border-color: #f44336;
}
.has-error .form-control:focus {
border-color: #f44336;
}
.has-error .input-group-addon {
color: #f44336;
background-color: #f2dede;
border-color: #f44336;
}
.has-error .form-control-feedback {
color: #f44336;
}
.has-feedback label ~ .form-control-feedback {
top: 25px;
}
.has-feedback label.sr-only ~ .form-control-feedback {
top: 0;
}
.input-group {
position: relative;
display: table;
border-collapse: separate;
}
.input-group .form-control {
position: relative;
z-index: 2;
float: left;
width: 100%;
margin-bottom: 0;
}
.input-group .form-control:focus {
z-index: 3;
}
.input-group-addon,
.input-group-btn,
.input-group .form-control {
display: table-cell;
}
.input-group-addon,
.input-group-btn {
width: 1%;
white-space: nowrap;
vertical-align: middle;
}
.input-group-addon {
padding: 6px 12px;
font-weight: normal;
line-height: 1;
color: #555;
text-align: center;
background-color: #fff;
border: 1px solid #ccc;
border-radius: 4px;
}
.input-group-addon.input-sm {
padding: 5px 10px;
font-size: 12px;
border-radius: 3px;
}
.input-group-addon.input-lg {
padding: 10px 16px;
font-size: 18px;
border-radius: 6px;
}
.input-group-addon input[type="radio"],
.input-group-addon input[type="checkbox"] {
margin-top: 0;
}
.input-group .form-control:first-child,
.input-group-addon:first-child,
.input-group-btn:first-child > .btn,
.input-group-btn:first-child > .btn-group > .btn,
.input-group-btn:first-child > .dropdown-toggle,
.input-group-btn:last-child > .btn:not(:last-child):not(.dropdown-toggle),
.input-group-btn:last-child > .btn-group:not(:last-child) > .btn {
border-top-right-radius: 0;
border-bottom-right-radius: 0;
}
.input-group-addon:first-child {
border-right: 0;
}
.input-group .form-control:last-child,
.input-group-addon:last-child,
.input-group-btn:last-child > .btn,
.input-group-btn:last-child > .btn-group > .btn,
.input-group-btn:last-child > .dropdown-toggle,
.input-group-btn:first-child > .btn:not(:first-child),
.input-group-btn:first-child > .btn-group:not(:first-child) > .btn {
border-top-left-radius: 0;
border-bottom-left-radius: 0;
}
.input-group-addon:last-child {
border-left: 0;
}
label {
display: inline-block;
max-width: 100%;
font-size: 13px;
margin-bottom: 5px;
}
input:focus{
outline:none!important;
}
.form-control-feedback i{
margin-top: -5px;
}
.form-group{
margin-bottom: 10px;
}
.footer-section{
background-color: #e9ecef;
display: grid;
border-top: 1px solid #d8dadd;
grid-template-columns:1fr;
font-size: 11px;
text-align: center;
}
/* ==========================================================================
Button Scripts
========================================================================== */
.btn{
display: inline-block;
margin-bottom: 0;
font-weight: 400;
text-align: center;
vertical-align: middle;
touch-action: manipulation;
cursor: pointer;
border: 1px solid transparent;
white-space: nowrap;
padding: 3px 10px;
line-height: 1.5384616;
border-radius: 3px;
-webkit-user-select: none;
-moz-user-select: none;
-ms-user-select: none;
user-select: none
}
.btn:focus{
outline: none;
}
.btndrk-orange{
background-color: #ec8b02;
color:#fff;
}
<div class="login-wrapper">
<div class="content">
<div class="panel">
<div class="panel-body">
<div class="form-group">
<div class="input-group">
<span class="input-group-addon"><i class="icon-user-tie"></i></span>
<input type="text" class="form-control" name="username" id="username" autocomplete="off" placeholder="Username">
</div>
</div>
<div class="form-group">
<div class="input-group">
<span class="input-group-addon"><i class="icon-lock2"></i></span>
<input type="password" class="form-control" name="password" id="password" autocomplete="off" placeholder="Password">
</div>
</div>
</div>
<div class="panel-footer text-right">
<button type="button" class="btn">LOGIN</button>
</div>
</div>
</div>
</div>
Use display flex not display table on your input group.

Change text hover

How change text when I push cursor in button? If I push cursor in button with price, will show text: "Add to basket".
This is Code:
body {
font-family: 'Roboto', sans-serif;
}
.price {
font-size: 1em;
border-radius: 50px;
background-color: #f00;
text-align: center;
color: #fff;
padding: 5px;
width: 10%;
margin: 20px auto;
}
.price:hover {
background-color: #fff;
border: 1px solid #bfbfbf;
color: #f00;
cursor: pointer;
}
.info {
display: none;
}
<link href="https://fonts.googleapis.com/css?family=Roboto" rel="stylesheet"/>
<div class="price">$50</div>
<div class="info">Add to basket</div>
How solve this problem?
You can use a wrapper div to catch the over, I think is more maintainable if you change the html in the future:
body {
font-family: 'Roboto', sans-serif;
}
.price {
font-size: 1em;
border-radius: 50px;
background-color: #f00;
text-align: center;
color: #fff;
padding: 5px;
width: 10%;
margin: 20px auto;
}
.price:hover {
background-color: #fff;
border: 1px solid #bfbfbf;
color: #f00;
cursor: pointer;
}
.info {
display: none;
width: 20%;
margin: 20px auto;
cursor: pointer;
}
.wrapper:hover .info {
display: block;
}
<link href="https://fonts.googleapis.com/css?family=Roboto" rel="stylesheet"/>
<div class="wrapper">
<div class="price">$50</div>
<div class="info">Add to basket</div>
</div>
you can use :active to show text when mouse is clicking down on the price like so:
.price {
font-size: 1em;
border-radius: 50px;
background-color: #f00;
text-align: center;
color: #fff;
padding: 5px;
width: 10%;
margin: 20px auto;
}
.price:hover {
background-color: #fff;
border: 1px solid #bfbfbf;
color: #f00;
cursor: pointer;
}
.info {
display: none;
}
.price:active + .info {
display: block;
}
<div class="price">$50</div>
<div class="info">Add to basket</div>
if you are trying to show the text on :hover like the title of the question says the unser :hover like so:
.price {
font-size: 1em;
border-radius: 50px;
background-color: #f00;
text-align: center;
color: #fff;
padding: 5px;
width: 10%;
margin: 20px auto;
}
.price:hover {
background-color: #fff;
border: 1px solid #bfbfbf;
color: #f00;
cursor: pointer;
}
.info {
display: none;
}
.price:hover + .info {
display: block;
}
<div class="price">$50</div>
<div class="info">Add to basket</div>
Update 3:
.price {
font-size: 1em;
border-radius: 50px;
background-color: #f00;
text-align: center;
color: #fff;
padding: 5px;
width: 10%;
margin: 20px auto;
}
.price:hover {
background-color: #fff;
border: 1px solid #bfbfbf;
color: #f00;
cursor: pointer;
}
.info,
.price:hover .amount {
display: none;
}
.price:hover .info {
display: block;
}
<div class="price">
<div class="amount">$50</div>
<div class="info">Add to basket</div>
</div>

ul below the input element is not occupying the same width of the input element

I have a input text and below this input text I want to have a div with a green color that has some text. But I want that this green area to occupy the same with of the input element, but it is not working. Do you know what is not correct?
.main-search {
width: 100%;
position: relative;
background-color: yellow;
}
.search {
margin: 20px auto;
width: 100%;
font-size: 0.85em;
float: left;
background-color: white;
padding: 50px;
border-radius: 4px;
}
.search_auto_complete {
background-color: green;
text-align: left;
color: gray;
font-size: 1.1em;
border: 1px solid black;
z-index: 10;
position: fixed;
width: inherit;
padding: 0 !important;
}
.search_auto_complete li {
padding: 10px;
background-color: $color-white;
border-bottom: 1px solid $color-gray;
}
.auto_complete_category {
background-color: $color-light-plus !important;
color: $color-gray-plus-plus;
font-weight: bold;
}
.auto_complete_category:hover {
background-color: $color-light-plus !important;
cursor: auto !important;
color: $color-gray-plus-plus !important;
}
.events_auto_complete li:hover {
background-color: $color-primary;
cursor: pointer;
color: $color-white;
}
.search_events_box button {
border-left: none;
color: #fff;
font-weight: 700;
padding: 17px;
}
.input_search_event {
position: relative;
border: 1px solid red;
}
* {
margin: 0;
padding: 0;
box-sizing: border-box;
-moz-box-sizing: border-box;
-webkit-box-sizing: border-box;
outline: 0;
}
input {
padding-left: 40px !important;
}
input {
padding: 15px;
width: 100%;
}
.content {
float: left;
width: 100%;
}
.div {
width: 60%;
margin: 0 auto;
padding: 20px 0;
}
<section class="content main-search">
<div class="div">
<h1>Title</h1>
<div class="search">
<div class="input_search">
<input id="auto" value="category" type="text">
<ul class="search_auto_complete">
<li class="auto_complete_category">Categories</li>
<li>Category 1</li>
</ul>
</div>
</div>
</div>
</section>
Example: https://jsfiddle.net/k9uL4zon/
Add position: relative to your container .input_search and replace position: fixed with position: absolute and width: inherit with width: 100% for your element .search_auto_complete. Demo:
.input_search {
position: relative; /* new */
}
.main-search {
width: 100%;
position: relative;
background-color: yellow;
}
.search {
margin: 20px auto;
width: 100%;
font-size: 0.85em;
float: left;
background-color: white;
padding: 50px;
border-radius: 4px;
}
.search_auto_complete {
background-color: green;
text-align: left;
color: gray;
font-size: 1.1em;
border: 1px solid black;
z-index: 10;
position: absolute;
width: 100%;
padding: 0 !important;
}
.search_auto_complete li {
padding: 10px;
background-color: $color-white;
border-bottom: 1px solid $color-gray;
}
.auto_complete_category {
background-color: $color-light-plus !important;
color: $color-gray-plus-plus;
font-weight: bold;
}
.auto_complete_category:hover {
background-color: $color-light-plus !important;
cursor: auto !important;
color: $color-gray-plus-plus !important;
}
.events_auto_complete li:hover {
background-color: $color-primary;
cursor: pointer;
color: $color-white;
}
.search_events_box button {
border-left: none;
color: #fff;
font-weight: 700;
padding: 17px;
}
.input_search_event {
position: relative;
border: 1px solid red;
}
* {
margin: 0;
padding: 0;
box-sizing: border-box;
-moz-box-sizing: border-box;
-webkit-box-sizing: border-box;
outline: 0;
}
input {
padding-left: 40px !important;
}
input {
padding: 15px;
width: 100%;
}
.content {
float: left;
width: 100%;
}
.div {
width: 60%;
margin: 0 auto;
padding: 20px 0;
}
<section class="content main-search">
<div class="div">
<h1>Title</h1>
<div class="search">
<div class="input_search">
<input id="auto" value="category" type="text">
<ul class="search_auto_complete">
<li class="auto_complete_category">Categories</li>
<li>Category 1</li>
</ul>
</div>
</div>
</div>
</section>

Resources