background:url(../images/list01.png) no-repeat 0 center;是什么意思

本文详细解释了CSS中background-position属性的用法,包括如何通过不同单位(如百分比和像素)来设定背景图像的位置,以及预设的关键字定位方式。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

例子:

background:url(../images/list01.png) no-repeat 0 center;
background:url(../images/bg.png) no-repeat -4px -3px;
background:url(../images/list01.png) no-repeat 0 center;
的意思是 图像地址 不重复 水平位置0 垂直位置居中

0 center 的意思就是 水平位置0 垂直位置居中
-4px -3px 的意思就是 水平位置-4px  垂直位置-3px 

这两个值和background-position 属性是一样的,即设置背景图像的起始位置。
这个属性设置背景原图像的位置,背景图像如果要重复,将从这一点开始。
默认值:0% 0%
可能的值
 top left
 top center
 top right
 center left
 center center
 center right
 bottom left
 bottom center
 bottom right (以上,如果您仅规定了一个关键词,那么第二个值将是"center"。)

 x% y% ( 第一个值是水平位置,第二个值是垂直位置。左上角是 0% 0%。右下角是 100% 100%。如果您仅规定了一个值,另一个值将是 50%。)

mpx npx (第一个值是水平位置,第二个值是垂直位置。左上角是 0 0。单位是像素 (0px 0px) 或任何其他的 CSS 单位。如果您仅规定了一个值,另一个值将是50%。)
 
您可以混合使用 % 和 position 值。




//绘制路线周边设备上图 showDevicesOnMap(devices) { this.clearDeviceMarkers(); console.log("位置--===", devices); // devices.forEach((device, index) => { // const { longitude, latitude } = device; // const markerElement = document.createElement("div"); // markerElement.style.position = "relative"; // markerElement.style.width = "34px"; // markerElement.style.height = "50px"; // // 设备图标 // const icon = document.createElement("div"); // icon.style.width = "30px"; // icon.style.height = "20px"; // icon.style.backgroundImage = device.online // ? 'url("/images/jk_online.png")' // : 'url("/images/jk_unline.png")'; // icon.style.backgroundSize = "100% 100%"; // icon.style.backgroundRepeat = "no-repeat"; // icon.style.position = "absolute"; // 改为绝对定位 // icon.style.top = "10px"; // 调整顶部位置以适应容器 // icon.style.left = "50%"; // markerElement.appendChild(icon); // // 序号标签 // const label = document.createElement("div"); // label.textContent = index + 1; // label.style.position = "absolute"; // label.style.top = "0px"; // label.style.left = "50%"; // label.style.transform = "translateX(-50%)"; // label.style.backgroundColor = // this.selectedDeviceId === device.id ? "#FF6666" : "#45CCDA"; // label.style.color = "white"; // label.style.borderRadius = "50%"; // label.style.width = "20px"; // label.style.height = "20px"; // label.style.textAlign = "center"; // label.style.lineHeight = "20px"; // label.style.fontSize = "12px"; // label.style.zIndex = "10"; // 确保标签在最上层 // markerElement.appendChild(label); // // 计算图标实际尺寸 // const iconHeight = 50; // 图标高度(包含标签) // // 直接使用原始坐标,不进行任何偏移计算 // const marker = new minemap.Marker(markerElement, { // offset: [0, -iconHeight / 2], // 垂直偏移补偿 // anchor: "center", // 使用中心定位 // }) // .setLngLat([longitude, latitude]) // 直接使用原始坐标 // .addTo(this.mapObj); // // 点击事件 // markerElement.addEventListener("click", (e) => { // e.stopPropagation(); // this.toggleDeviceSelection(device.id, label); // }); // this.deviceMarkers.push({ marker, device, label }); // }); // 创建新的数据源 // 创建GeoJSON数据源 } toggleDeviceSelection(deviceId, labelElement) { // 更新选中状态 const isSelected = this.selectedDeviceId === deviceId; this.selectedDeviceId = isSelected ? null : deviceId; // 更新标签颜色 labelElement.style.backgroundColor = isSelected ? "#45CCDA" : "#FF6666"; // 通知父组件 this.$emit("device-selected", this.selectedDeviceId, deviceId); },把这些替换为图层标记的方法类似于 // const dataSource = { // type: "FeatureCollection", // features: devices.map((device) => ({ // id: device.id, // type: "Feature", // geometry: { // type: "Point", // coordinates: [device.longitude, device.latitude], // }, // properties: { // ...device, // title: device.name, // "custom-image": device.online ? "jk_online" : "jk_unline", // index: device.index || 1, // 添加序号属性 // }, // })), // }; // // 设置数据源 // const mapSource = this.mapObj.getSource("data-point"); // mapSource.setData(dataSource);
07-24
<template> <view class="bg-content"> <z-paging ref="paging1" v-model="dataList" @query="queryList"> <view slot="top"> <view class="tablesChange"> <view class="tables"> <u-tabs :list="tabsList4" @click="clickTabFn" :scrollable="true" lineColor="#FF6400" :activeStyle="{color: '#303133',fontWeight: 600,transform: 'scale(1.05)',fontSize: '31rpx'}" :inactiveStyle="{color: '#606266',fontWeight:500,transform: 'scale(1)',fontSize: '31rpx'}" itemStyle="padding-left: 30rpx; padding-right: 30rpx; height: 80rpx;"> </u-tabs> </view> </view> </view> <!-- <view class="my-evaluate f-jcsb f-a-i" @click="navMyevaluateFn" v-if="actTab==3"> <view class="f-a-i"> <u-icon type="eye" size="20" color="#fff"></u-icon> <u-icon name="chat" color="#999" size="18"></u-icon> 我的评价 </view> <view> <u-icon name="arrow-right" color="#999" size="18"></u-icon> </view> </view> --> <view> <view @click="jump()" class="list-cont" v-for="(item,index) in dataList" :key="index" > <canvas style="width:220rpx;height:86rpx;" canvas-id="colorCanvas"></canvas> <view class="top-flex"> <text class="grayfont">2025-7-10 11:29:15</text> <text style="font-weight: 500;">待支付</text> </view> <view class="main"> <image src="/static/images/tabbar/showroom_active.png" mode=""></image> <view class="main-msg"> <text class="font">东风风行E702022款500超享版</text> <view class="car-money"> <text class="blue-font">¥<text style="padding-right: 10rpx;">210000</text>元</text> </view> <view class="profit-estimate"> <text class="profit-label">预估可赚</text> <text class="profit-value">30000元</text> </view> </view> </view> <view class="main-bto"> <text>车辆年限:1年内</text> <text>公里数:1.78万公里</text> <text>使用性质:非营运</text> </view> </view> </view> </z-paging> </view> </template> <script> import { tabsList4 } from "@/data/tabsData2.js" export default { data() { return { tabsList4, actTab: -1, dataList: [], buttStyle: { width: '160rpx', height: '56rpx', marginLeft: '16rpx' }, imageUrl: 'https://cbl.diyouzhijia.com/static/images/ygctzmp/home/backgroundHeader.png', dominantColor: '', topUpTypeShow: false, topUpType: 'ye', payPrice: 0, payData: { from: "", orderNo: "", payChannel: "yue", payType: "yue", scene: 0 } }; }, onLoad(){ this.getImageColor() }, methods: { // 加载图片时获取背景? getImageColor(){ var _this = this const ctx = uni.createCanvasContext('colorCanvas') ctx.drawImage(_this.imageUrl, 0, 0, 100, 100) // 缩小到1像素分析 console.log(ctx,"ctx"); ctx.draw(true, () => { console.log("背景背景背景背景"); uni.canvasGetImageData({ canvasId: 'colorCanvas', x: 0, y: 0, width: 100, height: 100, success: res => { console.log(res,"res"); const [r, g, b] = res.data _this.dominantColor = `rgb(${r}, ${g}, ${b})` console.log('主色调:', _this.dominantColor) } }) }) }, jump(){ uni.navigateTo({ url:'/pagesB/home/publish' }) }, topUpTypeClose() { this.topUpTypeShow = false }, // 去支付 //详情 navParticularFn(item) { uni.navigateTo({ url:'/pagesA/showroom/newPayOrder/detalorder?orderId='+item.id }) }, clickTabFn(tab) { this.actTab = tab.value this.$refs.paging1.refresh(); }, //订单列表 queryList(pageNo, pageSize) { // 此处请求仅为演示,请替换为自己项目中的请求 let obj = { page: pageNo, limit: pageSize, type: this.actTab } let arr=[ { name:'1', value:'2' }, { name:'2', value:'3' } ] this.$refs.paging1.complete(arr); // getInformationOrderList(obj).then(res => { // this.$refs.paging.complete(res.data.list); // }) }, }, onShow() { if (this.$refs.paging1) { this.$refs.paging1.refresh(); } } } </script> <style lang="scss" scoped> .bg-content { min-height: 100vh; background: #F6F7FB; } .order-list-butt { width: 100%; padding: 0 24rpx; .order-list-butt-go { width: 120rpx; font-size: 24rpx; font-weight: 400; color: #999999; image { width: 48rpx; height: 48rpx; } } .order-list-butt-refund { padding: 16rpx 24rpx; font-size: 24rpx; font-weight: 400; color: #111111; background: #F5F5F5; margin-top: 16rpx; } } .user-data { padding: 24rpx 24rpx 0 24rpx; .user-data-image { width: 48rpx; height: 48rpx; border-radius: 50%; background: #f5f5f5; image { width: 100%; height: 100%; } } .user-data-name { font-size: 28rpx; font-weight: 400; color: #000000; margin-left: 16rpx; } .user-data-state { font-size: 24rpx; font-weight: bold; color: #FF6400; } } .car-rental { width: calc(100% - 48rpx); margin: 24rpx 24rpx 0 24rpx; padding-bottom: 24rpx; border-bottom: 1rpx solid #eee; .car-rental-cont { height: 150rpx; width: calc(100% - 218rpx); margin-left: 16rpx; display: flex; flex-direction: column; justify-content: space-around; .car-rental-cont-name { font-size: 32rpx; font-weight: 400; color: #111111; } .car-rental-cont-price { font-size: 32rpx; font-weight: bold; color: #111111; } .car-rental-cont-total-payment { font-size: 24rpx; font-weight: 400; color: #666666; } } image { width: 202rpx; height: 150rpx; } } .list-cont { // width: calc(100% - 30rpx); margin: 24rpx; background: #fff; border-radius: 8rpx; padding-bottom: 24rpx; // border: 1px solid red; padding: 30rpx; .top-flex{ display: flex; width: 100%; padding-bottom: 26rpx; justify-content: space-between; align-items: center; border-bottom: 1px solid #DBDBDB; text{ font-size: 28rpx; color: #2F74FA; font-weight: 500; } .grayfont{ color: #666666; font-size: 28rpx; } } .main-bto{ display: flex; width: 100%; align-items: center; justify-content: space-between; color: #666666; font-size: 24rpx; text{ padding-top: 30rpx; } } .main{ display: flex; align-items: center; justify-content: space-between; border-bottom: 1px solid #DBDBDB; padding-bottom: 30rpx; margin-top: 30rpx; image{ width: 259rpx; height: 180rpx; border-radius: 10rpx; } .main-msg{ flex: 1; height: 100%; margin-left: 30rpx; display: flex; flex-direction: column; justify-content: space-between; .car-money{ margin-top: 10rpx; .blue-font{ color: #FF6400; font-size: 24rpx; text{ font-size: 36rpx; } } } // .bg-money{ // width: 100%; // height: 44rpx; // margin-top: 10rpx; // font-size: 24rpx; // font-weight: 500; // color: white; // line-height: 44rpx; // // border: 1px solid #3E80F5; // background: url('https://cbl.diyouzhijia.com/static/images/ygcmp/home/yugu.png') no-repeat; // background-size: 100% 100%; // } .profit-estimate { display: flex; align-items: center; width: 100%; height: 48rpx; margin-top: 10rpx; // margin-bottom: 30rpx; color: white; background: url('https://cbl.diyouzhijia.com/static/images/ygcmp/home/yugu.png') no-repeat; background-size: 100% 100%; .profit-label { color: #ffffff; font-weight: 700; font-size: 24rpx; margin: 0 31rpx 0 13rpx; } .profit-value { flex: 1; text-align: center; font-weight: 700; color: #2f74fa; font-size: 32rpx; } } .font{ color: #333333; font-size: 28rpx; // margin-top: 10rpx; font-weight: 500; display: -webkit-box; -webkit-box-orient: vertical; -webkit-line-clamp: 2; /* 限制显示的行数 */ overflow: hidden; text-overflow: ellipsis; } } } } .tab-list { background: #fff; overflow: auto; view { width: 88rpx; padding-bottom: 12rpx; border-bottom: 6rpx solid transparent; font-size: 29rpx; font-weight: bold; display: inline-block; color: #555555; text-align: center; } .act-tab { border-bottom: 6rpx solid #000; font-size: 29rpx; font-weight: bold; color: #222222; } } .act-flaf { width: calc(100% - 56rpx); margin-left: 24rpx; } .circle { width: 30rpx; height: 30rpx; border-radius: 50%; border: 2rpx solid #D7D7D7; } .my-evaluate { background: #fff; padding: 16rpx 24rpx; width: calc(100% - 48rpx); margin: 24rpx; border-radius: 8rpx; } .tablesChange{ // padding: 0px 30rpx; .tables{ background-color: white; // border-radius: ; border-radius: 20rpx 20rpx 0px 0px; padding: 30rpx 20rpx; padding-bottom: 0px; } } </style> 上面代码中console.log('主色调:', _this.dominantColor)一直获取的rgb(0, 0, 0)
最新发布
07-24
<template> <div class="nav has-pe" :class="isDark ? 'dark' : ''"> <div class="header-bg"> <!-- <img :src="headerBg" style="width:100%;"/>--> </div> <!-- <div class="animate-blocks">--> <!-- <div v-for="i in 3" class="animate-block-item"></div>--> <!-- </div>--> <div class="animate-1-con"><img :src="animate1Image" class="animate-1-img"/></div> <div class="animate-2-con"><img :src="animate2Image" class="animate-2-img"/></div> <!-- <div class="star"></div>--> <div style="height:100%;display: flex;align-items: center;"> <div class="logo-con has-pe" style="height:100%;"> <div class="logo-border"> <logo-svg class="logo-svg" /> </div> <router-link :to="{name:'home'}" class="logo-text"> {{appStore.title}} </router-link> </div> <div class="menu-con has-pe"> <template v-for="m in menus"> <a v-if="m.href" :href="m.href" target="_blank" class="menu-item nav-ab t" :class="m.code"> <span class="mdi mgr-5" :class="m.icon"></span> <span>{{m.text}}</span> </a> <router-link v-else :to="{name: m.code}" @click="play" class="menu-item nav-ab t" :class="m.code"> <span class="mdi mgr-5" :class="m.icon"></span> <span>{{m.text}}</span> </router-link> </template> </div> <div class="right-side text-right mgr-10 mgt-5"> <div class="font-18">欢迎你,超级管理员</div> <div class="font-ntf font-20 mgt-5 op-60"> <el-button size="small" type="primary" plain class="is-square" icon="Sunny" @click="appStore.toggleTheme()"></el-button> <el-button size="small" type="primary" plain class="is-square" icon="FullScreen" @click="toggleFullscreen()"></el-button> <el-button size="small" type="primary" plain class="is-square" icon="MoreFilled"></el-button> <el-button size="small" type="danger" plain>退出</el-button> </div> </div> </div> </div> </template> <script setup lang="ts"> import _ from "lodash" import {computed, onMounted, ref, onUnmounted} from "vue"; import {useAppStore} from "@/services/store/app"; import {Howl} from 'howler'; import menuSound from "@/assets/medias/menu.mp3" import {useNow, useDateFormat, useDark} from '@vueuse/core' import animate1Image from "./images/animate-1.png" import animate2Image from "./images/animate-2.png" import logoSvg from "@/assets/images/logo.svg" const appStore = useAppStore(); const now = useNow(); const nowTime = ref('') const timer = ref() const isDark = useDark(); //region sound var sound = new Howl({ src: [menuSound], volume: .4 }); const play = () => { sound.play(); }; //endregion const menus = [ {code:'home', text:'首页', icon:'mdi-home'}, {code:'network', text:'网络', icon:'mdi-lan'}, {code:'transfer', text:'数据', icon:'mdi-transfer'}/*, {code:'stat', text:'检索统计', icon:'mdi-chart-bar-stacked', href: headerQueryMenuUrl}, {code:'manage', text:'后台管理', icon:'mdi-monitor-dashboard', href:headerManageMenuUrl}*/ ]; import {usePageAnimate} from "@/services/hook/usePageAnimate"; import axios from "axios"; usePageAnimate("nav-ab"); onMounted(() => { }); onUnmounted(()=> { }) import { useFullscreen } from '@vueuse/core' import {headerManageMenuUrl, headerQueryMenuUrl} from "@/services/config"; const { isFullscreen, enter, exit, toggle: toggleFullscreen } = useFullscreen() </script> <style lang="scss" scoped> @use "sass:math"; @import "@/assets/css/_var"; $padding: 36px; .nav { position:absolute; left:$padding;right:$padding;top:$padding; z-index:10; height:80px; backdrop-filter: blur(3px); //box-shadow: 0 1px 10px rgba(0,0,0,.3) //background-color: rgba(red,.5); } .header-bg { //height: 90px; width:100%; //background: url(./images/header-bg.png) no-repeat bottom center; //background-size: contain; position: absolute; z-index:0; top:0;left:0;right:0;bottom:0; border-top: transparent solid 6px; border-bottom: transparent solid 1px; background: rgba($-primary-color, 0.3); border-top-color:$-primary-color; border-bottom-color: $-primary-color; box-shadow: 0 0 6px #035f71; &:after { content:""; position: absolute;top:0;bottom:0;left:0;right:0; //background: linear-gradient(45deg , rgba($-primary-color , .5) 60%, $-primary-color); } } .right-side { position: relative; } .logo-con { display: flex; align-items: center; justify-content: center; } .logo-border { //background:rgba(255,255,255,.1); padding:0 25px;display:flex;align-items:center; height:100%; position:relative;z-index:1; border-top:transparent solid 6px; border-bottom:transparent solid 6px; box-shadow: 1px 0 10px rgba(0,0,0,.2); border-color: rgba($-primary-color, 1);; } .logo-svg { width:60px;margin-left1:10px; //filter: drop-shadow( 0px 0px 6px rgba(#bcffff, .3)); //fill: #00c8e1; :deep { path {fill:#253223} path.lightning { fill:#ffcc00; stroke-width: 0; } //.circle-middle { // fill: #ffcc00; //} .dot {fill:#ffcc00;} .circle-bg {fill:transparent} } } .logo-text { padding-left:20px; font-family: shuhei;font-size:42px; margin-top:3px; text-shadow1: 5px 5px 1px rgba(255,255,255,.1); filter: drop-shadow( 1px 1px 2px #253223); background-image: -webkit-linear-gradient(90deg, rgb(245, 255, 250) , $-primary-color ); //background-image: linear-gradient(180deg,#fff,#2af1f8); -webkit-background-clip: text; -webkit-text-fill-color: transparent; } .menu-con { display: flex; flex:1; justify-content: center; position:relative;z-index:1; margin-top:6px; } .menu-item { display: flex; align-items: center;justify-content: center; border:rgba(#253223,.9) solid 1px; background: rgba($-primary-color,.4); color:rgba(#253223, .8); border-radius:2px; width:150px;height:44px; margin:0 15px; background-size:cover; text-align:center; font-size:20px; font-family: fzzzh; font-weight: normal; letter-spacing: 5px; transition: all .3s; span.mdi {opacity: .9} &:after, &:before { transition: all .3s; content:''; position: absolute; width:3px;height:24px; background: rgba(#253223,.6) } &:before {left:0;} &:after { right:0; } &:hover { border-color:#253223; color:#253223; background: rgba(#fff, .8); &:after, &:before { height:28px; background: rgba(#253223,.9) } &:after {right:3px} &:before {left:3px} } &.router-link-active { span.mdi {opacity: 1} color: $-primary-color; border-width:2px; border-radius:4px; border-color:$-primary-color; background: rgba(14, 31, 14,.9); font-weight:bold; box-shadow: 0 0 8px #253223; &:after, &:before { width:4px; background: rgba($-primary-color,.8) } } &.job, &.live, &.vehicle{ text-decoration: line-through; } } .animate-blocks { width: 55px; height: 25px; left: 662px; top: 74px; position: absolute; visibility: visible; pointer-events: none; transition: transform 600ms; display: flex; align-items: center; justify-content: space-evenly; } .animate-block-item { width:8px;height:10px; background: linear-gradient(to right , rgba(120, 255, 255, .8) , transparent); transform: skewX(-40deg); border-radius:1px; } .animate-1-con { position: absolute; pointer-events: none; left: 399px; top: 0; width: 120px; height: 100%; opacity:.3; } .animate-1-img { width:100%;height:100%; border-radius: unset; cursor: pointer; pointer-events: none; animation-name: animate-1; animation-iteration-count: infinite; animation-timing-function: linear; animation-duration: 5s; animation-delay: 0s; -webkit-user-drag: none; filter: none; } @keyframes animate-1 { 0% { opacity: 0; transform: none; } 15% { opacity: 0.75; transform: rotateX(0deg) rotateY(0deg) rotateZ(0deg) scaleX(1) scaleY(1) translate3d(150px, 0px, 0px); } 30% { opacity: 1; transform: rotateX(0deg) rotateY(0deg) rotateZ(0deg) scaleX(1) scaleY(1) translate3d(300px, 0px, 0px); } 45% { opacity: 0.75; transform: rotateX(0deg) rotateY(0deg) rotateZ(0deg) scaleX(1) scaleY(1) translate3d(450px, 0px, 0px); } 60% { opacity: 0; transform: rotateX(0deg) rotateY(0deg) rotateZ(0deg) scaleX(1) scaleY(1) translate3d(600px, 0px, 0px); } 100% { opacity: 0; transform: rotateX(0deg) rotateY(0deg) rotateZ(0deg) scaleX(1) scaleY(1) translate3d(600px, 0px, 0px); } } .animate-2-con { position: absolute; pointer-events: none; left: 646px; bottom: 0; width: 120px; height: 60%; opacity:.3; } .animate-2-img { width:100%;height:100%; border-radius: unset; cursor: pointer; pointer-events: none; animation-name: animate-2; animation-iteration-count: infinite; animation-timing-function: linear; animation-duration: 4s; animation-delay: 0s; -webkit-user-drag: none; filter: none; } @keyframes animate-2 { 0% { opacity: 0; transform: none; } 50% { opacity: .78; transform: translateX(450px); } 100% { opacity: 0; transform: translateX(900px); } } $star-width: math.div(1120px, 1.5); $star-height: math.div(660px, 1.5); .star { position:absolute;top:-113px;left:-10px; width:$star-width;height:$star-height; background: url(./images/star.png) no-repeat bottom center; background-size: cover; animation-name: star-animate; animation-iteration-count: infinite; animation-timing-function: linear; animation-duration: 10s; animation-delay: 10s; -webkit-user-drag: none; //filter: brightness(150%); } @keyframes star-animate { 0% { opacity: 1; } 50% { opacity: .5; } 100% { opacity: 1; } } div.nav.dark { .header-bg { border-top-color:rgb(71, 128, 76); border-bottom-color:rgba(6, 253, 253, .15); background: rgba($-primary-color, 0.3); //background-color: rgba(106, 211, 137, 0.12); &:after { background: linear-gradient(-45deg , rgba(0,0,0,.4), transparent); } } .logo-border { border-color: rgb(71, 128, 76); } .logo-text { background-image: -webkit-linear-gradient(90deg, rgb(150, 248, 140) 0%, rgb(245, 255, 250) 90%); } .logo-svg { :deep { path {fill:rgba(113, 228, 102,.6)} path.lightning { fill:#ffcc00; stroke-width: 0; } //.dot {fill:rgba(#fff,.7);} .circle-bg {fill:transparent} } } $-menu-color: #71e466; //7cffff .menu-item { border:rgba($-menu-color,.3) solid 1px; background: rgba(0,0,0,.2); color:rgba($-menu-color, .5); &:after, &:before { background: rgba($-menu-color,.3) } &:hover { border-color:$-menu-color; color:$-menu-color; background: rgba($-menu-color, .1); &:after, &:before { background: rgba($-menu-color,.6) } } &.router-link-active { color: $-menu-color; border-color:$-menu-color; &:after, &:before { background: rgba($-menu-color,.8) } } } } </style>
07-22
<!DOCTYPE html> <html lang="en"> <head> <meta charset="UTF-8"> <meta name="viewport" content="width=device-width, initial-scale=1.0"> <title>学习天地</title> {% load static %} <!-- 加载静态文件标签 --> <style> /* 设置背景图片 */ body { min-height: 10vh; /* 设置最小高度为视口高度 */ margin: 0; /* 移除默认边距 */ padding: 0; /* 移除默认内边距 */ font-family: Arial, sans-serif; background-image: url("{% static 'images/学习天地.jpg' %}"); <!-- 使用静态文件标签加载图片 --> background-size: cover; /* 宽度 300px,高度自动调整 */ background-position: center; <!-- 图片居中显示 --> background-attachment: fixed; background-repeat: no-repeat; <!-- 防止图片重复 --> color: white; <!-- 设置文字颜色为白色,确保在背景上清晰可见 --> } /* 其他样式保持不变 */ .course-list { list-style-type: none; padding: 0; } .course-item { background-color: rgba(249, 249, 249, 0.8); <!-- 添加透明度,使背景图片可见 --> margin: 10px 0; padding: 15px; border-radius: 5px; box-shadow: 0 0 10px rgba(0, 0, 0, 0.1); } .course-item a { color: #007BFF; text-decoration: none; } .course-item a:hover { text-decoration: underline; } .pagination { margin-top: 20px; text-align: center; } .pagination a { margin: 0 5px; color: #007BFF; text-decoration: none; } .pagination a:hover { text-decoration: underline; } </style> </head> <body> <h1 style="font-size: 100px; color:rgb(14, 84, 204);">学习天地</h1> <a href="{% url 'home' %}" style="font-size: 50px; color:rgb(183, 118, 5);">点击进入主页</a> </body> </html>代码运行后,浏览器只能显示背景图片的一部分
03-19
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值