#python #html #css
Вопрос:
Я конвертирую свой html-код в pdf на Python и не могу понять, как вставить мини-логотип в нижний колонтитул/заголовок. В основном я не знаю, как вставить html-теги для вставки моего изображения. Я искал другие сообщения в стеке, но в данном случае они были полезны. Любая помощь будет признательна!
<html>
<head>
<style>
h2 {
text-align: center;
font-family: Helvetica, Arial, sans-serif;
}
thead,
tfoot {
background-color: #3f87a6;
color: #fff;
}
table {
margin-left: auto;
margin-right: auto;
}
table, th, td {
border: 2px solid black;
border-collapse: collapse;
}
tr:nth-child(even) {
background-color: #f2f2f2;
}
th, td {
padding: 5px;
text-align: center;
font-family: Helvetica, Arial, sans-serif;
font-size: 80%;
}
table tbody tr:hover {
background-color: #e4f0f5;
}
.wide {
width: 95%;
}
result = '<h2> %s </h2>n' % title
if type(df) == pd.io.formats.style.Styler:
result = df.render()
else:
try:
result = df.to_html(classes='wide', escape=False)
except: #si son series conviértelo a dataframe
result = df.to_frame().to_html(classes='wide', escape=False)
result = '''
</body>
</html>
'''
with open(filename, 'w') as f:
f.write(result)
Ответ №1:
Я думаю, что это будет полезно.
/* Style the header with a grey background and some padding */
.header {
overflow: hidden;
background-color: #f1f1f1;
padding: 20px 10px;
}
/* Style the header links */
.header a {
float: left;
color: black;
text-align: center;
padding: 12px;
text-decoration: none;
font-size: 18px;
line-height: 25px;
border-radius: 4px;
}
/* Style the logo link (notice that we set the same value of line-height and font-size to prevent the header to increase when the font gets bigger */
.header a.logo {
font-size: 25px;
font-weight: bold;
}
/* Change the background color on mouse-over */
.header a:hover {
background-color: #ddd;
color: black;
}
/* Style the active/current link*/
.header a.active {
background-color: dodgerblue;
color: white;
}
/* Float the link section to the right */
.header-right {
float: right;
}
/* Add media queries for responsiveness - when the screen is 500px wide or less, stack the links on top of each other */
@media screen and (max-width: 500px) {
.header a {
float: none;
display: block;
text-align: left;
}
.header-right {
float: none;
}
}
<div class="header">
<a href="#default" class="logo">CompanyLogo</a>
<div class="header-right">
<a class="active" href="#home">Home</a>
<a href="#contact">Contact</a>
<a href="#about">About</a>
</div>
</div>