style:refine tabsview css

This commit is contained in:
Pan 2017-10-31 14:42:58 +08:00
parent 2c868f47d9
commit d56831679e
5 changed files with 79 additions and 16 deletions

View file

@ -1,6 +1,6 @@
<template>
<a href="https://github.com/PanJiaChen/vue-element-admin" target="_blank" class="github-corner" aria-label="View source on Github">
<svg width="80" height="80" viewBox="0 0 250 250" style="fill:#4AB7BD; color:#fff; position: absolute; top: 50px; border: 0; right: 0;"
<svg width="80" height="80" viewBox="0 0 250 250" style="fill:#4AB7BD; color:#fff; position: absolute; top: 84px; border: 0; right: 0;"
aria-hidden="true">
<path d="M0,0 L115,115 L130,115 L142,142 L250,250 L250,0 Z"></path>
<path d="M128.3,109.0 C113.8,99.7 119.0,89.6 119.0,89.6 C122.0,82.7 120.5,78.6 120.5,78.6 C119.2,72.0 123.4,76.3 123.4,76.3 C127.3,80.9 125.5,87.3 125.5,87.3 C122.9,97.6 130.6,101.9 134.4,103.2"

View file

@ -0,0 +1,51 @@
<template>
<div class='scroll-container' ref='scrollContainer' @mousewheel="handleScroll">
<div class='scroll-wrapper' ref='scrollWrapper' :style="{left: left + 'px'}">
<slot></slot>
</div>
</div>
</template>
<script>
export default {
name: 'scrollPane',
data() {
return {
left: 0
}
},
methods: {
handleScroll(e) {
e.preventDefault()
const $container = this.$refs.scrollContainer
const $containerWidth = $container.offsetWidth
const $wrapper = this.$refs.scrollWrapper
const $wrapperWidth = $wrapper.offsetWidth
console.log($containerWidth, $wrapperWidth)
if (e.wheelDelta > 0) {
this.left = Math.min(0, this.left + e.wheelDelta)
} else {
if ($containerWidth - 100 < $wrapperWidth) {
if (this.left < -($wrapperWidth - $containerWidth + 100)) {
this.left = this.left
} else {
this.left = Math.max(this.left + e.wheelDelta, $containerWidth - $wrapperWidth - 100)
}
} else {
this.left = 0
}
}
}
}
}
</script>
<style rel="stylesheet/scss" lang="scss" scoped>
.scroll-container {
white-space: nowrap;
position: relative;
.scroll-wrapper {
position: absolute;
}
}
</style>

View file

@ -4,6 +4,7 @@
@import './sidebar.scss';
body {
height: 100%;
-moz-osx-font-smoothing: grayscale;
-webkit-font-smoothing: antialiased;
text-rendering: optimizeLegibility;
@ -15,9 +16,14 @@ label {
}
html {
height: 100%;
box-sizing: border-box;
}
#app{
height: 100%;
}
*,
*:before,
*:after {

View file

@ -12,10 +12,10 @@
<router-link class="pan-btn pink-btn" to="/excel/download">Excel</router-link>
</el-col>
<el-col :span="4" class='text-center'>
<router-link class="pan-btn green-btn" to="/example/table/table">Table</router-link>
<router-link class="pan-btn green-btn" to="/example/table/complex-table">Table</router-link>
</el-col>
<el-col :span="4" class='text-center'>
<router-link class="pan-btn tiffany-btn" to="/example/form/edit">Form</router-link>
<router-link class="pan-btn tiffany-btn" to="/form/edit-form">Form</router-link>
</el-col>
<el-col :span="4" class='text-center'>
<router-link class="pan-btn yellow-btn" to="/theme/index">Theme</router-link>

View file

@ -1,14 +1,19 @@
<template>
<div class='tabs-view-container'>
<router-link class="tabs-view-item" :class="isActive(tag.path)?'active':''" v-for="tag in Array.from(visitedViews)" :to="tag.path" :key="tag.path">
<scroll-pane class='tabs-view-container'>
<router-link class="tabs-view-item" :class="isActive(tag.path)?'active':''" v-for="tag in Array.from(visitedViews)" :to="tag.path"
:key="tag.path">
{{tag.name}}
<span class='el-icon-close' @click='closeViewTabs(tag,$event)'></span>
</router-link>
</div>
</scroll-pane>
</template>
<script>
import ScrollPane from '@/components/ScrollPane'
export default {
components: { ScrollPane },
computed: {
visitedViews() {
return this.$store.state.app.visitedViews
@ -44,6 +49,7 @@ export default {
isActive(path) {
return path === this.$route.path
}
},
watch: {
$route() {
@ -57,25 +63,25 @@ export default {
.tabs-view-container {
background: #fff;
height: 34px;
line-height: 34px;
border-bottom: 1px solid #d8dce5;
box-shadow: 0 2px 4px 0 rgba(0, 0, 0, .12), 0 0 6px 0 rgba(0, 0, 0, .04);
box-shadow: 0 1px 3px 0 rgba(0, 0, 0, .12), 0 0 3px 0 rgba(0, 0, 0, .04);
.tabs-view-item {
display: inline-block;
position: relative;
height: 32px;
line-height: 32px;
height: 26px;
line-height: 26px;
border: 1px solid #d8dce5;
color: #495060;
background: #fff;
padding: 0 12px;
padding: 0 8px;
font-size: 12px;
margin-left: 10px;
margin-left: 5px;
margin-top: 4px;
&:first-of-type {
margin-left: 0px;
margin-left: 15px;
}
&.active {
border-bottom: 0px;
background-color: #eef1f6;
&::before {
content: '';
background: #20a0ff;