Issue
Sorry i'm very new to dash, css, html coding.
i'm using Dash on Python and i would like a simple full page background with an image.
i'm using this CSS: https://codepen.io/chriddyp/pen/bWLwgP.css
i tried to use different CSS (https://necolas.github.io/normalize.css/8.0.1/normalize.css) beacuse i read it was a margin problem but it didn't work
i've read a lot of discussion about this issue but i wasn't able to fix it for my purposes
external_stylesheets = ['https://codepen.io/chriddyp/pen/bWLwgP.css']
app = dash.Dash(__name__,
external_stylesheets = external_stylesheets)
app.title = "Q"
colors = {'background': '#ffffff',
'bg_home': '#666666',
'text': '#ffa500',
'background_plot': '#cccccc',
'text_plot': '#000000'}
app.config['suppress_callback_exceptions']=True
image = 'url(https://c.wallhere.com/photos/a1/fc/1920x1080_px_Albert_Einstein_Formula_mathematics_physics_science_Special_Relativity-549404.jpg!d)'
app.layout = html.Div(
className='row',
style={
'verticalAlign':'middle',
'textAlign': 'center',
'background-image':image,
},
children= [
html.Div(
id='Username',
style={'textAlign': 'center',
'verticalAlign':'middle',
},
children= [
html.H3('Login',
style={'textAlign': 'center',
'color':'orange',
'fontWeight': 'bold',
},
),
html.Div(
className='row',
children=[
dcc.Input(id = 'user',
style={'margin-top':20},
type='text',
placeholder='Username'
)
]
),
html.Div(className='row',
children=[
dcc.Input(id = 'psw',
style={'margin-top':20},
type='text',
placeholder='Password'
)
]
),
html.Div(className='row',
children=[
html.Button('Login',
id='log',
style={'background-color':'white',
'color':'black',
'margin-top': 20,
'textAlign':'right'},
),
]
)
])
]
)
if __name__ == '__main__':
app.run_server(debug=True,host='0.0.0.0',port=8050)
i'm not gettin error but i just get 1/3 (more or less) of the page with background image and login Div, the rest of the page completely white.
I just would like a full page with background image and login in the center
Thank you all
Solution
In css body
tag defines the document's whole body and the div
is a part of it, there are two ways to get this working.
- Make the
div
to cover the entire page and set the image to thediv
Refer here: Making a div that covers the entire page
Modified bit of code,
className='row',
style={
'verticalAlign':'middle',
'textAlign': 'center',
'background-image':image,
'position':'fixed',
'width':'100%',
'height':'100%',
'top':'0px',
'left':'0px',
'z-index':'1000'
},
- Modify the
body
tag in theexternal_stylesheet
to have the propertybackground-image
,
body {
'background-image' : url(url!d);
}
Answered By - n00b
0 comments:
Post a Comment
Note: Only a member of this blog may post a comment.