홈>
현재 마우스를 클릭하면 색상이 변하는 클릭 가능한 상자가 많이 있습니다. 특정 상자를 길게 클릭하면 색상이 변경됩니다 (CSS에서 : active를 사용하여
어쨌든 다른 상자를 클릭 할 때까지 테두리의 색을 영구적으로 변경할 수 있습니까? 예를 들어 마우스를 붙잡을 필요가 없다는 점을 제외하고 : active 속성과 동일합니까?
내 코드 : flight-viewer.html
<h3>Flights </h3>
<div>
<ul class= "grid grid-pad">
<a *ngFor="let flight of flights" class="col-1-4">
<li class ="module flight" (click)="selectFlight(flight)">
<h4>{{flight.number}}</h4>
</li>
</a>
</ul>
</div>
<div class="box" *ngIf="flightClicked">
<!--<flight-selected [flight]="selectedFlight"></flight-selected>-->
You have selected flight: {{selectedFlight.number}}<br>
From: {{selectedFlight.origin}}<br>
Leaving at: {{selectedFlight.departure || date }}<br>
Going to: {{selectedFlight.destination}}<br>
Arriving at: {{selectedFlight.arrival || date}}
</div>
flight-viewer.css :
h3 {
text-align: center;
margin-bottom: 0;
}
h4 {
position: relative;
}
ul {
width: 1600px;
overflow-x: scroll;
background: #ccc;
white-space: nowrap;
vertical-align: middle;
}
div
{
position:absolute;
top:50%;
left:50%;
transform:translate(-50%,-50%);
}
li {
display: inline-block;
/* if you need ie7 support */
*display: inline;
zoom: 1
}
.module {
padding: 20px;
text-align: center;
color: #eee;
max-height: 120px;
min-width: 120px;
background-color: #607D8B;
border-radius: 2px;
}
.module:hover {
background-color: #EEE;
cursor: pointer;
color: #607d8b;
}
.module:active {
border: 5px solid #73AD21;
}
.box {
text-align: center;
margin-bottom: 0;
margin: auto;
width: 600px;
position:absolute;
top: 180px;
right: 0;
height: 100px;
border: 5px solid #73AD21;
text-align: center;
display: inline-block;
}
flight-viewer-component.ts :
import { Component } from '@angular/core';
import { FlightService } from './flight.service';
import { Flight } from './flight.model'
@Component({
selector: 'flight-viewer',
templateUrl: 'app/flight-viewer.html',
styleUrls: ['app/flight-viewer.css']
})
export class FlightViewerComponent {
name = 'FlightViewerComponent';
errorMessage = "";
stateValid = true;
flights: Flight[];
selectedFlight: Flight;
flightToUpdate: Flight;
flightClicked = false;
constructor(private service: FlightService) {
this.selectedFlight = null;
this.flightToUpdate = null;
this.fetchFlights();
}
flightSelected(selected: Flight) {
console.log("Setting selected flight to: ", selected.number);
this.selectedFlight = selected;
}
flightUpdating(selected: Flight) {
console.log("Setting updateable flight to: ", selected.number);
this.flightToUpdate = selected;
}
updateFlight(flight: Flight) {
let errorMsg = `Could not update flight ${flight.number}`;
this.service
.updateFlight(flight)
.subscribe(() => this.fetchFlights(),
() => this.raiseError(errorMsg));
}
selectFlight(selected: Flight) {
console.log("Just click on this flight ", selected.number, " for display");
this.flightClicked = true;
this.selectedFlight = selected;
}
private fetchFlights() {
this.selectedFlight = null;
this.flightToUpdate = null;
this.service
.fetchFlights()
.subscribe(flights => this.flights = flights,
() => this.raiseError("No flights found!"));
}
private raiseError(text: string): void {
this.stateValid = false;
this.errorMessage = text;
}
}
감사합니다!
- 답변 # 1
관련 자료
- c# - Syncfusion MaskedTextBox의 테두리 색상을 변경할 수 없습니다
- VB.Net - vbnet - 패널의 테두리 색상 변경
- javascript - 텍스트 파일을 기반으로 버튼 색상을 변경하는 방법은 무엇입니까?
- mex - MATLAB R2019a mxArray 헤더가 변경 되었습니까?
- typescript - power bi custom visual - 날짜 슬라이서 수정시 색상 변경
- reactjs - 재질 UI 선택시 SVG 이미지 아이콘 색상 변경
- javascript - onclick () 변경 이미지가 계속 재설정됩니다
- html - CSS가 작동하지 않는 텍스트에 선형 그라디언트 테두리가있는 그라디언트 색상
- reactjs - 활성화 된 탭의 측면 테두리 색상을 변경하는 방법
- reactjs - 정렬 가능한 임시 반응 - 상태를 변경하는 방법을 클릭하십시오
- javascript - DOM에 액세스하고 요소 글꼴 및 색상 변경
- ggplot2 - ggplot/R에서 boxplot outline이 색상을 변경하지 않는 이유
- c# - DataGrid의 머리글 테두리 제거
- python 3.x - 버튼이 기능으로 만들어 질 때 버튼 색상을 변경하는 방법이 있습니까?
- jquery - 플라스크 wtforms에 오류가 발생할 때 부트 스트랩 양식 입력 필드의 테두리 색상을 어떻게 변경합니까?
- reactjs - 검도 반응의 세부 사항 행에 대한 세부 정보 확장/축소 열의 헤더를 변경하는 방법은 무엇입니까?
- angular - 클릭시 버튼의 배경색 변경
- julia - 4 차원에 따라 각 마커의 색상 변경
- get childitem - Powershell Export-CSV이지만 헤더 이름 변경
- css - element-ui의 헤더 행 배경색 변경
관련 질문
- javascript : Angular에서 입력 클릭 이벤트를 기반으로 페이지 위로 이동
- javascript : 내 웹 개발 code를 처리하는 데 어려움이 있습니다.
- javascript : RGB 값으로 회색 음영 얻기
- javascript : html, css, js로 onclick 이벤트를 어떻게 할 수 있습니까?
- javascript : 캔버스에서 버튼을 정렬하고 스타일을 지정하는 방법은 무엇입니까?
- javascript : 내 웹사이트의 모바일 버전 버거 버튼이 드롭다운되지 않음
- javascript : .click 토글 기능을 어떻게 재설정합니까?
- javascript : EventListener에서 JS 기본값을 깨는 함수 매개 변수
- JavaScript(DOM)를 사용하여 색상 변경
- javascript : 누구든지 배경색으로 캔버스 이미지를 저장하는 방법을 말해 줄 수 있습니까?
이것이 이미 답변 된 것 같습니다.
와이즈 비즈 와이즈 비즈그러면
yz:focus
를 사용할 수 있습니다 문제를 해결하기 위해 각도로 제공되는 지시문.이것은 CSS 클래스
[ngClass]
를 추가합니다<a *ngFor="let flight of flights" class="col-1-4"> <li [ngClass]="{'permanent-border': flight.id === selectedFlight?.id}" class ="module flight" (click)="selectFlight(flight)"> <h4>{{flight.number}}</h4> </li> </a>
에 요소, 비행 ID가 selectedFlight와 ID와 일치하는 경우 (ID proberty가 지정되었거나 비행에 고유 한 다른 proberty를 사용한다고 가정)permantent-border