Vuetify - Set background img - css

In Vuetify (Vue components super set) I want to add an image pattern in background.
I tried
body {
background: url("/images/background.png") no-repeat center center fixed;
background-size: cover;
}
But this doesn´t work, Some vuetify component cancels this style. I want an elegant way of doing this rather than inserting styles directly in the components or html.
Anybody faced this error? How do I fix it?

It's happen because the v-app replace the background style.
Try something like that:
div[data-app='true'] {
background: url('/images/background.png') no-repeat center center fixed !important;
background-size: cover;
}
The selector selected the element root of Vuetify (the v-app) and force to change the background style.
Or, you can use the name of your root element to change the background style. For example:
#app {
background: url('/images/background.png') no-repeat center center fixed !important;
background-size: cover;
}
PS: See the minimal example with this patch:
<template>
<div>
<v-app>
<v-content class="pa-4">
<v-data-table :headers="headers" :items="items" />
</v-content>
</v-app>
</div>
</template>
<script>
export default {
name: 'app',
data: () => ({
items: [
{ id: 1, name: 'Option 1' },
{ id: 2, name: 'Option 2' },
{ id: 3, name: 'Option 3' },
],
headers: [
{ text: 'Id', value: 'id' },
{ text: 'Name', value: 'name' },
],
}),
};
</script>
<style>
#app {
background: url('https://ohlaladani.com.br/wp-content/uploads/wallpaper-OHLALADANI_DESKTOP_WALLPAPERS_AVENTURA-2.jpg')
no-repeat center center fixed !important;
background-size: cover;
}
</style>

Put a class on your v-container
<template>
<v-container class="hero">
</v-container>
</template>
<style scoped>
.hero {
background: url('../assets/yourImage.jpg');
background-size: cover;
height: 100vh;
}
</style>

Related

How to dynamically update a background image based on routing in a React framework

I am trying to update a background image based on various routing options. However no background is displayed at all.
I've tried inline styling and making sure I'm referring to the right directories.
Originally the css just set the background by changing the html background but I could not make this dynamic.
class App extends Component {
constructor() {
super();
this.state = {
'route': 'Home'
}
}
onRouteChange = (route) => {
this.setState({route: route});
}
render() {
if (this.state.route === 'Home') {
return (
<div className='App home'>
<div style={{display: 'flex', justifyContent: 'flex-end', backgroundColor: 'rgb(91,121,97, 0.5)'}}>
<div style={{marginRight: 'auto'}}><Logo onRouteChange={this.onRouteChange}/></div>
<Navigation onRouteChange={this.onRouteChange}/>
</div>
<SideBar/>
</div>
)
} else {
return(
<div className='App theAnimalKingdom'>
<div style={{display: 'flex', justifyContent: 'flex-end', backgroundColor: 'rgb(91,121,97, 0.5)'}}>
<div style={{marginRight: 'auto'}}><Logo onRouteChange={this.onRouteChange}/></div>
<Navigation onRouteChange={this.onRouteChange}/>
</div>
</div>
)
}
}
}
export default App;
The app.css is shown below.
div.app {
height: 100%;
width: 100%;
}
div.home {
background-image: url('./Images/cover.jpg') no-repeat center bottom fixed;
background-size: 100% 100%;
}
div.theAnimalKingdom {
background-image: url('./Images/other.jpg') no-repeat center bottom fixed;
background-size: 100% 100%;
}
If the this.status should change to theAnimalKingdom then the background should change to other.jpg
There is no such thing as ./something (relative paths to "current" folder) for CSS <url> values of background-image.
You can use relative URLs, but those are relative to the CSS file (in build folder after the webpack/typescript/... compilation - if using create-react-app, assets from public folder are copied all, but assets from src only when actually imported).
Setting a backgroundImage With React Inline Styles might be easier, but placing the images to public folder is also possible.

Why Devextreme grid is overflowing its parent container and why it is not creating vertical scrollbars?

I have (https://codesandbox.io/s/9zok7jx4ro) the Devextreme grid with large number of items (the following codes shows only some of them) and the problem is that grid is overflowing the div element which contains this grid. I would like to ask the grid to create inner scrollbars and to respect the available space that is provided by the containing div elements. How can I do this?
I have the following code:
import React from "react";
import ReactDOM from "react-dom";
import {
Grid,
Table,
TableHeaderRow
} from "#devexpress/dx-react-grid-bootstrap4";
import "#devexpress/dx-react-grid-bootstrap4/dist/dx-react-grid-bootstrap4.css";
import "./styles.css";
//
function App() {
return (
<div className="App">
<Grid
className="grid"
rows={[
{ id: 0, product: "DevExtreme", owner: "DevExpress" },
{ id: 1, product: "DevExtreme Reactive", owner: "DevExpress" },
{ id: 2, product: "DevExtreme", owner: "DevExpress" },
{ id: 3, product: "DevExtreme Reactive", owner: "DevExpress" },
{ id: 4, product: "DevExtreme", owner: "DevExpress" },
]}
columns={[
{ name: "id", title: "ID" },
{ name: "product", title: "Product" },
{ name: "owner", title: "Owner" }
]}
>
<Table />
<TableHeaderRow />
</Grid>
</div>
);
html,
body {
width: 100%;
height: 100%;
margin: 0px;
}
#root {
width: 100%;
height: 100%;
margin: 0px;
}
.App {
width: 100%;
height: 100%;
margin: 0px;
font-family: sans-serif;
text-align: center;
background-color: rosybrown;
}
.grid {
width: 100%;
height: 100%;
background-color: magenta;
}
You have to give the grid some height(in pixels) if you want it to show vertical scrollbars. This is the case with most UIs and not just with Devextreme(JS). If you give it 100% height that some element up the DOM hierarchy must have fixed width for this to work.

ExtJS 6 - add resizable image / logo to a topmenu

I'm redesigning a frontend for a uni project written with ExtJS 6.
right now I'm wondering how to properly add an image to a container that fits the size:
I tried a displayfield using value: "img=.../>" but I can't seem to make the image fit properly - it's just way to big. The same goes for "html: img=.../>".
also adressing id: 'TopMenu' with #TopMenu{} in css seems to have no effect whatsoever regardless of the options I try to change :(
I suspect ExtJS defaults have higher priority than my own settings or I'm simply not adressing the container right.
Ext.define('textImager.view.menu.TopMenu', {
extend: 'Ext.panel.Panel',
// id für css: #TopMenu
id: 'TopMenu',
xtype: 'TopMenu',
layout: 'hbox',
items: [
// goethe logo
{
flex: 1,
id: 'GoetheLogo'
},
// Website titel
{
flex: 8,
id: 'Titel',
html: 'TextImager'
},
// dropdown menu
{
flex: 1,
id: 'DropdownMenu',
xtype: 'button',
html: 'menu',
menu: [
{xtype: 'button',
html: 'test1'}]
},
]
});
the current css:
#TopMenu-body{}
#GoetheLogo-body{
background-image:url(../resources/images/menu/TT_logo_transparent.png);
background-position: right center;
background-size: contain;
background-repeat: no-repeat;
background: rgba(123,123, 123, 0.8);
}
#Titel{}
#DropdownMenu{}
simply resizing would be a bad workaround and I also have to adjust the background which currently is not working either.
I would greatly appreciate some insight on how to properly adress the containers with css.
I've found a solution - it might not be the best, but I'm quite happy with the result:
// TT logo mit Link zur Website
{
flex: 1,
xtype: 'button',
height: '100%',
//TODO: add link
html: '<div class="TT_logo"><img src="./resources/images/menu/TT_logo_transparent.png"></div>'
},
css:
.TT_logo{
width: 100%;
height: 100%;
background: rgba(0, 0, 0, 0.8);
}
.TT_logo img{
max-width: 100%;
max-height: 100%;
}

Why there are no icons for the buttons in itemselector?

I am trying to use the Ext.ux.form.ItemSelector,but no icons are on the add/remove/top/down buttons!
Code below:
Ext.create('Ext.ux.form.ItemSelector', {
renderTo: Ext.getBody(),
name: 'channelRange',
store: Ext.create('Ext.data.Store', {
fields: ['display', 'value'],
data: [{
display: '22',
value: 2
}, {
display: '33',
value: 3
}]
}),
buttons: ['add', 'remove'],//No icons on the buttons! Why?
//imagePath: '../ux/images/',
displayField: 'display',
valueField: 'value',
value : [ 3 ],
allowBlank: false
});
See the result here, the buttons between the 2 multiselect have no icon!
Yes it is an issue with ItemSelector. You will not see any icon on buttons after any kind of BUILD.
I was able to resolve this issue permanently via overriding below CSS. Actually if you debug the code you will see that it is trying to location these button icons on different location.
// Do these overrides in any of your CSS file.
.x-form-itemselector-top {
background-image: url(images/itemselector/top.gif) !important;
}
.x-form-itemselector-up {
background-image: url(images/itemselector/up.gif) !important;
}
.x-form-itemselector-add {
background-image: url(images/itemselector/right.gif) !important;
}
.x-form-itemselector-remove {
background-image: url(images/itemselector/left.gif) !important;
}
.x-form-itemselector-down {
background-image: url(images/itemselector/down.gif) !important;
}
.x-form-itemselector-bottom {
background-image: url(images/itemselector/bottom.gif) !important;
}
NOTE: Also make a sure you have these icons on given path (images/itemselector/). In my case I copied these icons from "ui-client\ext\packages\ux\classic\resources\images\itemselector" to "ui-client\resources\images\itemselector". Here "ui-client" is my application root folder.
Hope above provided information will help.
Solution from my project:
grid.tbar.push({
itemId : 'create',
iconCls : 'iconAdd',
text : 'Add'
}
and config in some .css file:
.iconAdd {background: url(/resources/img/action-add.png) no-repeat !important;}

Using icons with List items

I am using Sencha Touch 2.2.1 . I want to display list items with icons, for that I am using itemTpl config property of the list. The image is rendered as icon but the list item is not getting aligned properly- it appears starting from much below. I want the text to get started from the top- it must be aligned horizontally with the image. I also tried changing 'margin' property but it didn't seem to work.
Please find my code below:
Ext.define('BBraunSencha.view.ListPanel',{
extend: 'Ext.Panel',
xtype: 'listpanel',
config:{
layout:{
type: 'vbox',
align: 'stretch'
},
items:[
{
xtype: 'label',
html: '<div style="margin-left: 20px;">List one</div>'
},{
xtype: 'list',
flex: 1,
ui:'round',
scrollable: true,
data:[
{ name: 'item1', price:'2000',in_stock : 'no'},
{ name: 'item2', price: '3000',in_stock :'yes'}
],
itemTpl: '<img src="images/Tulips.jpg" style="height: 50px;width: 50px;display:inline-block;margin-right:50px;"/>{name}'
}
]
} });
What can be the other way to achieve it?
Add a class to your css, then use that class for your itemTpl:
CSS file:
.tulip-icon {
background-image: url(images/Tulips.jpg);
background-size: 50px 50px;
background-repeat: no-repeat;
padding-left: 50px;
}
JS Code:
itemTpl: '<div class="tulip-icon">{name}</div>'
Add css:
.list-image{
height:20px;
width:20px;
float: left;
}
in js file:
itemTpl:'<div><img src="images/Tulips.jpg" class="list-image">{name}</div>'

Resources