일모도원(日暮途遠) 개발자

[티스토리기능] 소스블럭이 길때 스크롤바 표시하기 본문

주절주절/티스토리 기능

[티스토리기능] 소스블럭이 길때 스크롤바 표시하기

달님개발자 2022. 9. 3. 20:05

소스코드를 블로그글에 넣으면 스크롤바가 없어서 아래 처럼 너무 길게 나올때가 있다.

이럴때는 CSS에 아래를 추가하자. (max-height는 각자에 맞게 적당하게 추가하자)
 
/* 소스코드블럭에 스크롤바 추가하기 추가 */

.hljs {max-widht:850px; max-height:300px; overflow:scroll !important;}

 

 

먼저 관리자페이지로 가서 스킨 편집을 선택하자.

 

 스킨편집에서 HTML편집을 선택한다.

 

CSS를 선택하고 적당한곳에 위 코드를 삽입하고 우측 적용 버튼을 누르자.

 

 

그러면 아래처럼 소스코드 블럭의 높이가 설정한 만큼 작아지며, 소스코드위로 마우스를 가져다가 스크롤을 하면 스크롤바가 표시된다.

 

 

override func awakeFromNib() {
    super.awakeFromNib()
//        cellBackground.backgroundColor = UIColor(named: "cellBackgroundColor_White")
    cellBackground.backgroundColor = AppLayout().darkMode_CellLightGrayColor()
    gradeKnowButton.layer.cornerRadius = 5.0
    grade1Button.layer.cornerRadius = gradeKnowButton.layer.cornerRadius
    grade2Button.layer.cornerRadius = gradeKnowButton.layer.cornerRadius
    gradeUnknowButton.layer.cornerRadius = gradeKnowButton.layer.cornerRadius

    gradeKnowButton.backgroundColor = AppColor.WordKnownColor.rawValue.getColor()
    grade1Button.backgroundColor = AppColor.WordPrimaryColor.rawValue.getColor()
    grade2Button.backgroundColor = AppColor.WordSecondaryColor.rawValue.getColor()
    gradeUnknowButton.backgroundColor = AppColor.DarkGrayColor.rawValue.getColor()

    gradeView.enableEvents(self)
}

override func setSelected(_ selected: Bool, animated: Bool) {
    super.setSelected(selected, animated: animated)
}
func reloadCurrentVoca() {
    if let voca = self.entity {
        loadData(entity: voca, screenType: self.screenType, tableMode: self.tableMode)
    }
}
func loadData(entity: VocaEntity, screenType: AppScreenConts, tableMode: Int) {
    self.entity = entity
    self.screenType = screenType
    self.tableMode = tableMode
    if tableMode == 1 {
        // Right
        gradeViewLeftCst.isActive = false
        gradeViewCenterCst.isActive = false
        gradeViewRightCst.isActive = true
    } else if tableMode == -1 {
        // Left
        gradeViewLeftCst.isActive = true
        gradeViewCenterCst.isActive = false
        gradeViewRightCst.isActive = false
    } else {
        // Center
        gradeViewLeftCst.isActive = false
        gradeViewCenterCst.isActive = true
        gradeViewRightCst.isActive = false
    }
    if (screenType == .MEMORIZATION || screenType == .VOCA_POPUP) {
        indexLabel.text = "\(entity.group_index)"
    } else if (screenType == .FREQUENCY) {
        indexLabel.text = "\(entity.frequency_index)"
    } else {
        indexLabel.text = "\(entity.index)"
    }
    countLabel.text = "\(TextKeys.FREQUENCY.rawValue.localized()): \(entity.FREQUENCY)"
    vocaLabel.attributedText = entity.attributedVocaString
    meaningLabel.isHidden = false
//        logFor.DLog(message: "\(entity.VOCA) = \(entity.VOCA_ID) - \(entity.VOCA_ID_TO_SEND_SERVER)")
    if (entity.VOCA_ID <= 0 && entity.VOCA_ID_TO_SEND_SERVER <= 0) {
        meaningLabel.attributedText = nil
        meaningLabel.text = "TEXT.WORD.NOT.EXISTING".localized()
    } else if (entity.attributedMeaningString != nil) {
        meaningLabel.text = ""
        meaningLabel.attributedText = entity.attributedMeaningString
    } else {
        // Hide meaning to keep meaning label spacing
        meaningLabel.text = " "
        meaningLabel.isHidden = true
    }
//        logFor.DLog(message: "\(indexLabel.text!).\(entity.VOCA_ID) - \(entity.vocaString)")
    if (AppConts.IS_MACOS || UIDevice.isPad) {
        bookButtonWidthCst.constant = 44.0
        bookButton.isHidden = false

        editMeaningButtonWidthCst.constant = bookButtonWidthCst.constant
        editMeaningButton.isHidden = false
    } else {
        bookButtonWidthCst.constant = 8.0
        editMeaningButtonWidthCst.constant = 0
        bookButton.isHidden = true
        editMeaningButton.isHidden = true
    }

//        gradeLabel.text = entity.gradeValue
//        gradeView.renderLayout(colors: entity.gradeColors)
    AppLayout().reloadGradeViews(gradeLabel, gradeView, entity)

    if (entity.gradeValue == "?") {
        gradeSelectionViewHeightCst.constant = 50.0
        gradeSelectionView.isHidden = false
    } else {
        gradeSelectionViewHeightCst.constant = 0
        gradeSelectionView.isHidden = true
    }
    if (entity.isUnknowPronounceVoca()) {
        pronounceImageView.isHidden = false
        pronounceImageView.image = UIImage(named: "icon-pronounce-unknown")
        gradeSelectionViewCenterCst.constant = -15.0
    } else {
        pronounceImageView.isHidden = true
        gradeSelectionViewCenterCst.constant = 0
    }
    speakerButton.isSelected = entity.isPlaying

    let vc = presenter?.getView()
    gradeView.mainView = vc as? Viewable
}