I am using a snippet of code I found that creates port-lets (kinda like panels).
This doesn't specifically have a header to it but I am trying to see if there can be any css added to create one.
<div class="portlet">
<div class="portlet-title">
<div class="caption">
<i class="glyphicon glyphicon-calendar"></i>
<span class="caption-subject text-uppercase"> Portlet</span>
<span class="caption-helper">weekly stats...</span>
</div>
<div class="actions">
<a href="javascript:;" class="btn">
<i class="glyphicon glyphicon-pencil"></i>
Edit
</a>
<a href="javascript:;" class="btn">
<i class="glyphicon glyphicon-paperclip"></i>
Add
</a>
<a href="javascript:;" class="btn btn-circle">
<i class="glyphicon glyphicon-resize-full"></i>
</a>
</div>
</div>
<div class="portlet-body">
<h4>Heading Text</h4>
<p>Duis mollis, est non commodo luctus, nisi erat porttitor ligula, eget lacinia odio sem nec elit. Cras mattis consectetur purus sit amet fermentum. Duis mollis, est non commodo luctus, nisi erat porttitor ligula, eget lacinia odio sem nec elit. Cras mattis consectetur purus sit amet fermentum. Duis mollis, est non commodo luctus, nisi erat porttitor ligula, eget lacinia odio sem nec elit. Cras mattis consectetur purus sit amet fermentum. Duis mollis, est non commodo luctus, nisi erat porttitor ligula, eget lacinia odio sem nec elit. Cras mattis consectetur purus sit amet fermentum. consectetur purus sit amet fermentum. Duis mollis, est non commodo luctus, nisi erat porttitor ligula, eget lacinia odio sem nec elit. Cras mattis consectetur purus sit amet fermentum.</p>
</div>
</div>
Here is the CSS :
.content {
padding: 30px;
background: #f1f3fa;
}
.margin-bottom-30 {
margin-bottom: 30px;
}
/* Portlet */
.portlet {
background: #fff;
padding: 20px;
}
.portlet.portlet-gray {
background: #f7f7f7;
}
.portlet.portlet-bordered {
border: 1px solid #eee;
}
/* Portlet Title */
.portlet-title {
padding: 0;
min-height: 40px;
border-bottom: 1px solid #eee;
margin-bottom: 18px;
}
.caption {
float: left;
display: inline-block;
font-size: 18px;
line-height: 18px;
}
.caption i {
color: #777;
font-size: 15px;
font-weight: 300;
margin-top: 3px;
}
.caption-subject {
color: #666;
font-size: 16px;
font-weight: 600;
}
.caption-helper {
padding: 0;
margin: 0;
line-height: 13px;
color: #9eacb4;
font-size: 13px;
font-weight: 400;
}
/* Actions */
.actions {
float: right;
display: inline-block;
}
.actions a {
margin-left: 3px;
}
.actions .btn {
color: #666;
padding: 3px 9px;
font-size: 13px;
line-height: 1.5;
background-color: #fff;
border-color: #ccc;
border-radius: 50px;
}
.actions .btn i {
font-size: 12px;
}
.actions .btn:hover {
background: #f2f2f2;
}
/* Inputs */
.inputs {
float: right;
display: inline-block;
padding: 4px 0;
margin-top: -10px;
}
.input-inline {
width: 240px;
display: inline-block;
vertical-align: middle;
}
/* Btn Circle */
.actions .btn.btn-circle {
width: 28px;
height: 28px;
padding: 3px 7px;
text-align: center;
}
.actions .btn.btn-circle i {
font-size: 11px;
}
JS Fiddle: https://jsfiddle.net/dmz9xxr2/
What I have tried:
With not knowing much about CSS, I was thinking that I would have to add a background color to a specified height starting from the top of the portlet (.portlet). I may need to add an additional div or span to get this to work but wanted to see if there was any css tricks that could pull this off.
End Goal:
You can use a pseudo element, i.e. ::before.
Updated fiddle
.portlet {
position: relative;
background: #fff;
padding: 20px;
z-index: 1;
}
.portlet::before {
content: '';
position: absolute;
top: 0;
left: 0;
right: 0;
height: 59px;
background: steelblue;
z-index: -1;
}
Related
This is my issue on code pen:
https://codepen.io/mch-sg/pen/zYaKdNg
The flexbox is centered on flex-start, but when I scroll to the bottom, the box starts to upwards, and I have absolutely no idea what causes this. I thought the sticky parameter had something to do with it, but I see that I need to search for help here.
/* PRIMARY ATTRIBUTES */
:root {
--bgc: #A793FE;
--dim: #939393;
--hrc: rgb(39, 39, 39, 0.1);
--bgswitchmode: #FFFFFF;
--iconbg: #FFFFFF00;
--txtcol: #000000; // #BB3333
}
body.dark-theme {
// body.dark-theme
--hrc: rgb(240, 240, 240, 0.1);
--bgswitchmode: #000000;
--txtcol: #FFFFFF;
--hrc: rgb(200, 200, 200, 0.2);
}
body {
height: 100%;
transition: 0.2s;
background-color: var(--bgswitchmode);
color: var(--txtcol); // #FBFAF9
font-family: 'Inconsolata', monospace;
margin-top: 100px;
margin-left: 100px;
margin-right: 8%;
max-width: 500px;
}
p {
margin: 0;
position: absolute;
top: 50%;
left: 25%;
-ms-transform: translate(-50%, -50%);
transform: translate(-50%, -50%);
align-items: center;
}
.top {
position: absolute;
width: 100%;
height: 70px;
text-align: center;
padding-top: 35px;
}
button {
float: left;
width: 0%;
height: 0%;
background-color: red; //var(--iconbg)
color: var(--txtcol);
font-size: 20px;
/* border-radius: 10px; */
border: none;
margin-top: 15px;
cursor: pointer;
}
.d {
background-color: red; //var(--iconbg)
color: var(--txtcol);
font-size: 20px;
/* border-radius: 10px; */
border: none;
/* margin-top: 15px; */
cursor: pointer;
}
.txt {
text-decoration: none;
font-kerning: normal;
font-family: "Segoe UI", Frutiger, "Frutiger Linotype", "Dejavu Sans", "Helvetica Neue", Arial, sans-serif;
font-weight: 400;
line-height: 30px;
}
a {
text-decoration: none;
}
h1 {
font-family: 'Segoe UI', sans-serif; // 'Lato', sans-serif;
font-size: 40px;
font-weight: 500; // 300
letter-spacing: 1px;
}
h2 {
font-family: 'Inconsolata', monospace;
font-size: 18px;
font-weight: 500;
letter-spacing: 1px;
text-transform: uppercase;
}
h3 {
font-family: 'Inconsolata', monospace;
font-size: 18px;
font-weight: 500;
letter-spacing: 0px;
text-transform: uppercase;
text-indent: 5%;
}
.head-title {
font-family: 'Segoe UI', sans-serif;
font-size: 30px;
font-weight: 400;
letter-spacing: 1px;
}
hr {
display: block;
height: 1px;
border: 0;
border-top: 1px solid var(--hrc);
margin: 1em 0;
padding: 0;
}
.overlay {
position: absolute;
height: 100%;
width: 100%;
top: 0;
bottom: 0;
right: 0;
left: 0;
background: white;
opacity: 0;
}
/* TYPOGRAPHY */
.text {
font-family: 'Inconsolata', monospace;
font-size: 17px;
line-height: 1.5;
}
.hlink {
/* color: rgb(175, 175, 175); */
color: var(--bgc); //
text-decoration: none;
transition: 0.2s;
cursor: pointer;
}
.hlink:hover {
/*color: #f5978e; #929da6*/
color: #939393; //
}
a:-webkit-any-link {
text-decoration: none;
}
.link {
/* color: rgb(175, 175, 175); */
font-family: 'Inconsolata', monospace;
color: var(--bgc); // #EE8869
text-decoration: none;
transition: 0.2s;
cursor: pointer;
}
.link:hover {
/*color: #f5978e; #929da6*/
color: #939393; //
}
.navhov {
/* color: rgb(175, 175, 175); */
color: var(--txtcol); // #FBFAF9
text-decoration: none;
/* transition: 0.2s; */
// font-size: 19px;
}
.navhov:hover {
/*color: #ffb086 #f5978e*/
transition: 0.2s;
color: var(--bgc); //
}
.dim {
color: var(--dim);
text-decoration: none;
transition: 0.2s;
}
img:hover {
transition: 0.2s;
color: var(--bgc); //
}
/* SELECTION */
::-moz-selection {
/* Code for Firefox */
color: var(--bgswitchmode);
background: var(--bgc); // #ffb086
}
::selection {
color: var(--bgswitchmode);
background: var(--bgc);
}
/* FLEXBOX */
.flexbox-container {
flex: 1;
overflow: auto;
height: 100%;
width: 100%;
top: 0;
left: 0;
position: fixed;
display: flex;
justify-content: center;
align-items: flex-start;
overflow: auto;
}
.flexbox-item {
width: 100%; // 95%
border: 0.1px solid rgb(39, 39, 39, 0.5);
border-radius: 25px;
padding: 50px;
align-items: center;
justify-content: center;
/* display: flex; */
}
.flexbox-item-1 {
align-items: center;
justify-content: center;
min-height: 100px;
border: 0.1px solid rgb(39, 39, 39, 0.2);
margin: 0px 0px 0px 50px;
/* margin: 150px 75px 150px 150px; */
/* 100px 0px 50px 50px */
display: relative;
overflow: auto;
top: 50%;
transform: translateY(-50%);
}
.flexbox-item-2 {
min-height: 100px;
border: 0.1px solid rgb(39, 39, 39, 0.2);
margin: 100px 50px 100px 50px;
/* 150px 150px 150px 75px */
/* 125px 175px 0px 125px */
display: relative;
overflow: auto;
/* width: 40%; */
}
div.sticky {
position: -webkit-sticky;
position: sticky;
align-items: center;
justify-content: center;
}
.sticky2 {
/* top: 50%; */
/* -ms-transform: translateY(-50%);
transform: translateY(-50%); */
}
.sg {
padding: 50px;
font-size: 20px;
}
.ss {
position: fixed;
}
body {
height: 100%;
overflow-y: hidden;
overflow-x: hidden;
-ms-overflow-style: none;
scrollbar-width: none;
}
html {
overflow-x: hidden;
}
.cent {
font-family: 'Inconsolata', monospace;
font-weight: 500;
text-decoration: none;
margin-left: 40%;
/* 43% */
font-size: 17px;
}
.mb {
margin-bottom: -10px;
}
.mbl {
margin-bottom: 150px;
}
ul.nav {
padding-left: 0px;
text-align: center;
}
ul.nav>li {
display: inline-block;
padding: 0px 50px;
}
ul.nav>li:hover {
background-color: #00000000;
}
ul.nav>li>a {
text-decoration: none;
}
.subhead {
font-size: 22px;
font-weight: 400;
}
.sublink {
font-size: 20px;
font-family: 'Inconsolata', monospace;
font-weight: 500;
}
<div class="flexbox-container">
<div class="flexbox-item flexbox-item-1 sticky sg">
<div class="cent"><a class="navhov" href="/norsa/">Home</a><br></div>
<div class="cent">
<a class="navhov" href="#section1"><br><br>1.0. Getting started</a><br></div>
<div class="cent ">
<a class="navhov" href="#section2"><br><br>2.0. Introduction</a><br></div>
<div class="cent mb">
<a class="navhov" href="#section3"><br><br>3.0. Business Strategy</a><br></div>
<div class="cent mb">
<a class="navhov" href="#section3-1"><br>⠀⠀⠀⠀3.1. Executive Summary</a><br></div>
<div class="cent mb">
<a class="navhov" href="#section3-2"><br>⠀⠀⠀⠀3.2. Products & Services</a><br></div>
<div class="cent mb">
<a class="navhov" href="#section3-3"><br>⠀⠀⠀⠀3.3. Market Analysis</a><br></div>
<div class="cent mb">
<a class="navhov" href="#section3-4"><br>⠀⠀⠀⠀3.4. Marketing & Sales</a><br></div>
<div class="cent mb">
<a class="navhov" href="#section3-5"><br>⠀⠀⠀⠀3.5. Company Organization</a><br></div>
<div class="cent mb">
<a class="navhov" href="#section3-6"><br>⠀⠀⠀⠀3.6. Financial Projections</a><br></div>
<div class="cent mb">
<a class="navhov" href="#section4"><br><br>4.0. Financial</a><br></div>
<div class="cent">
<a class="navhov dim" href="/norsa/helpme/"><br><br><br><br>Help me</a>
</div>
<div class="cent">
<a class="navhov dim" href="#sectionA"><br>About<br></a><br></div>
<div class="cent pleek"><img class="bi bi-moon d dim pleek" src="" height="0" width="0" onclick="dark()" />
<img class="bi bi-bookmark-heart-fill d dim" src="" style="margin-left: 35px;" height="0" width="0" />
</div>
</div>
<div class="flexbox-item flexbox-item-2 text">
<div id="section1" class="txt">
<h1>Help me</h1>
<h1 class="mb dim subhead">We are a simple website for businesses, providing a wide variety of company templates, from employee agreements to style guides and strategies.</h1><br>
<br> Maecenas nisl est, ultrices nec congue eget, auctor vitae massa. Fusce luctus vestibulum augue ut aliquet. Mauris ante ligula, facilisis sed ornare eu, lobortis in odio. Praesent convallis urna a lacus interdum ut hendrerit risus congue. Nunc
sagittis dictum nisi, sed ullamcorper ipsum dignissim ac. In at libero sed nunc venenatis imperdiet sed ornare turpis. Donec vitae dui eget tellus gravida venenatis. Integer fringilla congue eros non fermentum. Sed dapibus pulvinar nibh tempor porta.
Cras ac leo purus. Mauris quis diam velit. Lorem ipsum dolor sit amet, consectetur adipiscing elit. Phasellus imperdiet, nulla et dictum interdum, nisi lorem egestas odio, vitae scelerisque enim ligula venenatis dolor.
<br><br> Fusce luctus vestibulum augue ut aliquet. Phasellus imperdiet, nulla et dictum interdum, nisi lorem egestas odio, vitae scelerisque enim ligula venenatis dolor. Maecenas nisl est, ultrices nec congue eget, auctor vitae massa. Fusce luctus
vestibulum augue ut aliquet. Mauris ante ligula, facilisis sed ornare eu, lobortis in odio. Praesent convallis urna a lacus interdum ut hendrerit risus congue.
<br><br><br>
<hr/>
<br>
</div>
<div id="section2" class="txt">
<h2 class="mb"> 2.0.⠀⠀Introduction</h2> <br>
<a class="head-title">Whatever you do, don't quit.</a>
<br><br><br> Lorem ipsum dolor sit amet, consectetur adipiscing elit. Phasellus imperdiet, nulla et dictum interdum, nisi lorem egestas odio, vitae scelerisque enim ligula venenatis dolor. Maecenas nisl est, ultrices nec congue eget, auctor vitae
massa. Fusce luctus vestibulum augue ut aliquet.
<br><br>
<a class="link" href="/assets/" target="_blank">🡢 Business strategy</a><br>
<a class="link" href="/assets/" target="_blank">🡢 Download 'The Brand Guide'</a>
<br><br> Maecenas nisl est, ultrices nec congue eget, auctor vitae massa. Fusce luctus vestibulum augue ut aliquet.Mauris ante ligula, facilisis sed ornare eu, lobortis in odio. Praesent convallis urna a lacus interdum ut hendrerit risus congue.
Nunc sagittis dictum nisi, sed ullamcorper ipsum dignissim ac. In at libero sed nunc venenatis imperdiet sed ornare turpis. Donec vitae dui eget tellus gravida venenatis. Integer fringilla congue eros non fermentum. Sed dapibus pulvinar nibh tempor
porta. Cras ac leo purus. Mauris quis diam velit. Lorem ipsum dolor sit amet, consectetur adipiscing elit. Phasellus imperdiet, nulla et dictum interdum, nisi lorem egestas odio, vitae scelerisque enim ligula venenatis dolor.
<br><br><br>
<hr/>
<br>
</div>
</div>
I tried messing around with the margins and centering, as well as the sticky parameter, it did not work.
I apologize for the messy file :)
flex items are not supposed to have justify-content and align-items, though they are just ignored. Regarding your question, Remove sticky from the element position. That should solve it.
I have an aside section that I'd like to have centered using a media query, so that once it's viewed on a mobile, it'll be at the bottom of the page aligned horizontally. Just like this:
This is what it's currently doing:
I have some images and text I don't want to share so I'll change them for this question...
body {
font-family: Arial, Helvetica, sans-serif;
font-size: 15px;
line-height: 1.5;
padding: 0;
margin: 0;
background-color: white;
}
/*GLOBAL*/
.container {
width: 80%;
margin: auto;
overflow: hidden;
}
header ul {
padding: 0;
margin: 0;
}
.page-title {
font-size: 20px;
}
.page-title-center {
font-size: 20px;
text-align: center;
}
.subheading-center {
font-size: 15px;
text-align: center;
margin-top: 50px;
}
.dark {
padding: 15px;
background: #1CAC4B;
color: white;
margin-top: 10px;
margin-bottom: 10px;
}
.dark-center {
padding: 15px;
text-align: center;
background: #1CAC4B;
color: white;
margin: 10px;
}
#hyperlink {
color: #FFEE00;
}
#hyperlinkg {
color: #1CAC4B;
}
/*HEADER*/
header {
background: #1CAC4B;
color: #fff;
padding-top: 30px;
min-height: 70px;
border-bottom: #FFEE00 3px solid;
display: flex;
}
header a {
color: #fff;
text-decoration: none;
text-transform: uppercase;
font-size: 15px;
}
header li {
float: left;
display: inline;
padding: 0 10px 0 10px;
}
header #branding {
float: left;
}
header #branding-img img {
float: left;
width: 60px;
height: 60px;
padding: 0 20px 20px 0;
}
header #branding h1 {
margin: 0;
}
header nav {
float: right;
margin-top: 14px;
}
header .highlight, header .current a {
color: #FFEE00 /*YELLOW*/;
}
header a:hover {
color: #cccccc;
font-weight: bold;
}
/*SHOWCASE*/
#showcase {
background:url("../img/grass.jpg") no-repeat;
background-size: cover;
min-height: 450px;
text-align: center;
color: white;
}
#showcase h1 { /**/
margin-top: 150px;
font-size: 60px;
margin-bottom: 10px;
}
#showcase p {
font-size: 30px;
}
/* CONTACT INFO */
#contact {
color: white;
background: #1CAC4B;
padding: 25px;
border-bottom: #FFEE00 3px solid;
border-top: #FFEE00 3px solid;
}
#contact h1 {
float: left;
}
#contact p {
font-size: 20px;
margin-top: 22px;
font-weight: bold;
float: right;
}
/*BOXES*/
.boxes {
background: white; /*Background behind 3 circular images are white */
display: flex; /*Makes circles drop if page is squished */
flex-wrap: wrap; /*Makes circles in a horizontal row */
justify-content: center;
}
.boxes figure {
margin: 3.5%; /*makes it line up better */
text-align: center; /*Puts text in center*/
font-size: 20px;
}
.boxes figure img {
border-radius: 25px; /*Makes images circular */
width: 310px; /*Sets image width*/
height: 220px; /*Sets image height - heigh and width must be same to make it a circular */
box-shadow: gray 0 0 15px; /*Adds gray shadow to bottom of images */
}
/*MAIN-COL*/
article#main-col {
float: left;
width: 70%;
}
/*ABOUT PAGE SIDEBAR*/
aside#about-sidebar {
float: right;
margin-top: 50px;
}
aside#about-sidebar img {
width: 230px;
height: 184px;
/*257px*/
}
/*SERVICES*/
ul#services li {
list-style: none;
padding: 20px;
border: green solid 1px;
margin-bottom: 10px;
background: #e6e6e6;
}
/*SERVICES PAGE SIDEBAR*/
aside#service-sidebar {
float: right;
margin-top: 50px;
}
/*GALLERY SLIDESHOW*/
* {box-sizing: border-box}
.mySlides1, .mySlides2 {display: none}
img {vertical-align: middle;}
/* Slideshow container */
.slideshow-container {
max-width: 800px;
position: relative;
margin: auto;
padding: 10px;
}
/* Next & previous buttons */
.prev, .next {
cursor: pointer;
position: absolute;
top: 50%;
width: auto;
padding: 16px;
margin-top: -22px;
color: white;
font-weight: bold;
font-size: 18px;
transition: 0.6s ease;
border-radius: 0 3px 3px 0;
user-select: none;
}
/* Position the "next button" to the right */
.next {
right: 0;
border-radius: 3px 0 0 3px;
}
/* On hover, add a grey background color */
.prev:hover, .next:hover {
background-color: #f1f1f1;
color: black;
}
/*FOOTER*/
footer {
padding: 20px;
margin-top: 20px;
color: white;
background-color: #1CAC4B;
text-align: center;
}
/*MEDIA QUERIES*/
#media(max-width: 768px){
header #branding,
header nav,
header nav li,
#boxes .box,
article#main-col,
aside#sidebar {
float: none;
align-content: center;
text-align: center;
width: 100%;
}
header {
padding-bottom: 20px;
}
#showcase h1 {
margin-top: 40px;
}
}
<body>
<main>
<header>
<div class="container">
<div id="branding-img">
<a href="index.html"><img src="https://cdn3.iconfinder.com/data/icons/business-avatar-1/512/10_avatar-512.png">
</div>
<div id="branding">
<h1><span class="highlight">NAME SHORT</span>NAME</h1>
</div>
<nav>
<ul>
<li>Home</li>
<li class="current">About</li>
<li>Services</li>
<li>Gallery</li>
</ul>
</nav>
</div>
</header>
<section id="main">
<div class="container">
<article id="main-col">
<h1 class="page-title">About The Company</h1>
<p class="dark">
Curabitur non accumsan tortor. Nulla aliquet risus ac velit consequat pretium. Duis vulputate congue commodo. Proin id mauris velit. Curabitur vel neque congue turpis dictum tristique. Vestibulum sit amet placerat quam. Sed sodales, lacus fermentum condimentum congue, leo mi congue nibh, sit amet aliquam risus sapien ut tellus.Curabitur non accumsan tortor. Nulla aliquet risus ac velit consequat pretium. Duis vulputate congue commodo. Proin id mauris velit. Curabitur vel neque congue turpis dictum tristique. Vestibulum sit amet placerat quam. Sed sodales, lacus fermentum condimentum congue, leo mi congue nibh, sit amet aliquam risus sapien ut tellus.
</p>
<h1 class="page-title">About Me</h1>
<p class="dark">
Curabitur non accumsan tortor. Nulla aliquet risus ac velit consequat pretium. Duis vulputate congue commodo. Proin id mauris velit. Curabitur vel neque congue turpis dictum tristique. Vestibulum sit amet placerat quam. Sed sodales, lacus fermentum condimentum congue, leo mi congue nibh, sit amet aliquam risus sapien ut tellus.
<br>
<br>
Lorem ipsum dolor sit amet, consectetur adipiscing elit. Donec sit amet sapien quis felis imperdiet scelerisque. Maecenas vulputate, nisl quis laoreet efficitur, urna nunc viverra massa, placerat commodo ligula tellus vel lacus. Ut molestie, purus id gravida sollicitudin, ipsum ipsum scelerisque diam, quis hendrerit mauris massa vitae quam. Donec maximus, felis sit amet tincidunt pretium, justo tellus cursus ex, quis vestibulum felis risus sed velit. Vivamus varius sapien sit amet nisl iaculis, et aliquet risus lobortis. In eget ullamcorper augue. If you are interested you can call me using my email or phone number displayed on the <a id="hyperlink" href="index.html">Home</a> page.
</p>
</article>
<aside id="about-sidebar">
<div class="dark">
<img src="https://cdn3.iconfinder.com/data/icons/business-avatar-1/512/10_avatar-512.png">
<p>
PERSON NAME
</p>
</div>
</aside>
</div>
</section>
<footer>
<p>COMPANY</p>
</footer>
</main>
</body>
Of course, as soon as I spent 10 minutes making this question I figured out my problem within literally 10 seconds lol.
I doubt anyone else would have this problem but you never know, so I'll answer it and leave it here for anyone who needs it.
In the CSS file in the media queries section, I removed '#sidebar' from 'aside#sidebar {'
I'm new at this. I'm not sure what I'm doing wrong. I've tried both the absolute and relative position but I can't get the footer to go at the bottom of the page. I also don't want the fixed option. Can anyone tell what's wrong with it?
<!DOCTYPE html>
<html>
<head>
<title>after hours</title>
<link href="style.css" type="text/css" rel="stylesheet">
</head>
<body>
<div id="banner">
<div class="content">
<h1>as always <br> at this hour </h1>
<h1 class="maroon">time means <br> nothing</h1>
</div>
</div>
<div class="nav">
home
about
blog
portfolio
</div>
<div id="main">
<div class="about">
<p>Aenean ornare velit lacus, ac varius enim ullamcorper eu. Proin aliquam facilisis ante interdum congue. Integer mollis, nisl amet convallis, porttitor magna ullamcorper, amet egestas mauris. Ut magna finibus nisi nec lacinia. Nam maximus erat id euismod egestas. Pellentesque sapien ac quam. Lorem ipsum dolor sit nullam.</p>
</div>
<div class="content">
<p>Aenean ornare velit lacus, ac varius enim ullamcorper eu. Proin aliquam facilisis ante interdum congue. Integer mollis, nisl amet convallis, porttitor magna ullamcorper, amet egestas mauris. Ut magna finibus nisi nec lacinia. Nam maximus erat id euismod egestas. Pellentesque sapien ac quam. Lorem ipsum dolor sit nullam.</p>
<div class="rectangle">
<p>This is a rectangle.</p>
</div>
<div class="rectangle">
<p>This is a rectangle too.</p>
</div>
<div class="rectangle">
<p>This a rectangle as well.</p>
</div>
</div>
</div>
<footer>
<p>Aenean ornare velit lacus, ac varius enim ullamcorper eu. Proin aliquam facilisis ante interdum congue. Integer mollis, nisl amet convallis, porttitor magna ullamcorper, amet egestas mauris. Ut magna finibus nisi nec lacinia. Nam maximus erat id euismod egestas. Pellentesque sapien ac quam. Lorem ipsum dolor sit nullam.</p>
</footer>
</body>
</html>
This is the separate CSS code. I'm not sure if the footer should be a class or it can simply be a tag.
* {
margin: 0;
padding: 0;
}
* {
box-sizing: border-box;
}
body {
font-family: helvetica;
line-height: 25px;
font-size: 15px;
letter-spacing: 0.5px;
}
#banner {
background: url(imgs/1.jpg);
background-size: cover;
width: 100%;
height: 660px;
position: absolute;
}
#banner .content h1 {
text-align: center;
position: absolute;
top: 54%;
left: 42.6%;
padding: 30 30 60 30;
color: #d6d6d6;
font-size: 30px;
font-family: futura;
letter-spacing: 4px;
line-height: 30px;
/*
border: 1.5px solid white;
width: 260px;
height: 80px;
*/
}
#banner .content h1.maroon {
padding-top: 70px;
color: firebrick;
}
.nav {
position: relative;
top: 660px;
background-color: black;
width: 100%;
height: 60px;
text-align: center;
padding: 20px 0px;
margin-bottom: 30px;
}
.nav a {
position: relative;
text-transform: uppercase;
text-align: center;
color: white;
font-family: roboto;
font-weight: normal;
text-decoration: none;
font-size: 13px;
letter-spacing: 5px;
padding: 22px 40px;
display: inline;
}
.nav a:hover {
color: firebrick;
}
#main {
position: relative;
margin: 0 auto;
top: 670px;
width: 80%;
padding: 20px;
}
.about {
float: right;
width: 30%;
padding: 10px;
}
.rectangle {
padding: 30px;
display: inline-block;
text-align: center;
width: 180px;
height: 200px;
}
.content {
float: left;
width: 60%;
padding: 10px;
}
footer {
position: absolute;
right: 0;
bottom: 0;
left: 0;
width: 100%;
padding: 30px;
margin: 0 auto;
height: 300px;
}
Position everything relative, unless you really need to use absolute.
See working snippet using your code.
* {
margin: 0;
padding: 0;
}
* {
box-sizing: border-box;
}
body {
font-family: helvetica;
line-height: 25px;
font-size: 15px;
letter-spacing: 0.5px;
position: relative;
}
#banner {
background: url(imgs/1.jpg);
background-size: cover;
width: 100%;
height: 660px;
position: relative;
}
#banner .content h1 {
text-align: center;
position: absolute;
top: 54%;
left: 42.6%;
padding: 30 30 60 30;
color: #d6d6d6;
font-size: 30px;
font-family: futura;
letter-spacing: 4px;
line-height: 30px;
}
#banner .content h1.maroon {
position: relative;
padding-top: 70px;
color: firebrick;
}
.nav {
position: relative;
background-color: black;
width: 100%;
height: 60px;
text-align: center;
padding: 20px 0px;
margin-bottom: 30px;
clear: both;
}
.nav a {
position: relative;
text-transform: uppercase;
text-align: center;
color: white;
font-family: roboto;
font-weight: normal;
text-decoration: none;
font-size: 13px;
letter-spacing: 5px;
padding: 22px 40px;
display: inline;
}
.nav a:hover {
color: firebrick;
clear: both;
}
#main {
position: relative;
margin: 0 auto;
width: 80%;
padding: 20px;
clear: both;
}
.about {
float: right;
width: 30%;
padding: 10px;
}
.rectangle {
padding: 30px;
display: inline-block;
text-align: center;
width: 180px;
height: 200px;
}
.content {
width: 60%;
padding: 10px;
}
footer {
position: relative;
width: 100%;
padding: 30px;
margin: 0 auto;
height: 300px;
border: 1px solid red;
}
<!DOCTYPE html>
<html>
<head>
<title>after hours</title>
<link href="style.css" type="text/css" rel="stylesheet">
</head>
<body>
<div id="banner">
<div class="content">
<h1>as always <br> at this hour </h1>
<h1 class="maroon">time means <br> nothing</h1>
</div>
</div>
<div class="nav">
home
about
blog
portfolio
</div>
<div id="main">
<div class="about">
<p>Aenean ornare velit lacus, ac varius enim ullamcorper eu. Proin aliquam facilisis ante interdum congue. Integer mollis, nisl amet convallis, porttitor magna ullamcorper, amet egestas mauris. Ut magna finibus nisi nec lacinia. Nam maximus erat id euismod egestas. Pellentesque sapien ac quam. Lorem ipsum dolor sit nullam.</p>
</div>
<div class="content">
<p>Aenean ornare velit lacus, ac varius enim ullamcorper eu. Proin aliquam facilisis ante interdum congue. Integer mollis, nisl amet convallis, porttitor magna ullamcorper, amet egestas mauris. Ut magna finibus nisi nec lacinia. Nam maximus erat id euismod egestas. Pellentesque sapien ac quam. Lorem ipsum dolor sit nullam.</p>
<div class="rectangle">
<p>This is a rectangle.</p>
</div>
<div class="rectangle">
<p>This is a rectangle too.</p>
</div>
<div class="rectangle">
<p>This a rectangle as well.</p>
</div>
</div>
</div>
<footer>
<p>Footer text in here</p>
</footer>
</body>
</html>
If all you want to do is put the div at the botton of the screen then add this to your css:
.footer{
position: absolute;
bottom: 0;
}
When you scroll the footer will also move though. If you want it to stay in the same location then make position: fixed
In your HTML you are closing </footer> instead of close </div>.
And give position: relative to the main parent div and apply
.footer {
position: absolute;
bottom: 0;
}
this will work.
remove position: relative; #main id css.
* {
margin: 0;
padding: 0;
}
* {
box-sizing: border-box;
}
body {
font-family: helvetica;
line-height: 25px;
font-size: 15px;
letter-spacing: 0.5px;
}
#banner {
background: url(imgs/1.jpg);
background-size: cover;
width: 100%;
height: 660px;
}
#banner .content h1 {
text-align: center;
position:relative;
top: 54%;
left: 42.6%;
padding: 30 30 60 30;
color: #d6d6d6;
font-size: 30px;
font-family: futura;
letter-spacing: 4px;
line-height: 30px;
/*
border: 1.5px solid white;
width: 260px;
height: 80px;
*/
}
#banner .content h1.maroon {
padding-top: 70px;
color: firebrick;
position:relative;
}
.nav {
top: 660px;
background-color: black;
width: 100%;
height: 60px;
text-align: center;
padding: 20px 0px;
margin-bottom: 30px;
}
.nav a {
position: relative;
text-transform: uppercase;
text-align: center;
color: white;
font-family: roboto;
font-weight: normal;
text-decoration: none;
font-size: 13px;
letter-spacing: 5px;
padding: 22px 40px;
display: inline;
}
.nav a:hover {
color: firebrick;
}
#main {
/* position: relative;*/
margin: 0 auto;
top: 670px;
width: 80%;
padding: 20px;
}
.about {
float: right;
width: 30%;
padding: 10px;
}
.rectangle {
padding: 30px;
display: inline-block;
text-align: center;
width: 180px;
height: 200px;
}
.content {
float: left;
width: 60%;
padding: 10px;
}
footer {
/* position: absolute;*/
float: left;
right: 0;
bottom: 0;
left: 0;
width: 100%;
padding: 30px;
margin: 0 auto;
height: 300px;
}
<!DOCTYPE html>
<html>
<head>
<title>after hours</title>
<link href="style.css" type="text/css" rel="stylesheet">
</head>
<body>
<div id="banner">
<div class="content">
<h1>as always <br> at this hour </h1>
<h1 class="maroon">time means <br> nothing</h1>
</div>
</div>
<div class="nav">
home
about
blog
portfolio
</div>
<div id="main">
<div class="about">
<p>Aenean ornare velit lacus, ac varius enim ullamcorper eu. Proin aliquam facilisis ante interdum congue. Integer mollis, nisl amet convallis, porttitor magna ullamcorper, amet egestas mauris. Ut magna finibus nisi nec lacinia. Nam maximus erat id euismod egestas. Pellentesque sapien ac quam. Lorem ipsum dolor sit nullam.</p>
</div>
<div class="content">
<p>Aenean ornare velit lacus, ac varius enim ullamcorper eu. Proin aliquam facilisis ante interdum congue. Integer mollis, nisl amet convallis, porttitor magna ullamcorper, amet egestas mauris. Ut magna finibus nisi nec lacinia. Nam maximus erat id euismod egestas. Pellentesque sapien ac quam. Lorem ipsum dolor sit nullam.</p>
<div class="rectangle">
<p>This is a rectangle.</p>
</div>
<div class="rectangle">
<p>This is a rectangle too.</p>
</div>
<div class="rectangle">
<p>This a rectangle as well.</p>
</div>
</div>
</div>
<footer>
<p>this is footer part <br/>Aenean ornare velit lacus, ac varius enim ullamcorper eu. Proin aliquam facilisis ante interdum congue. Integer mollis, nisl amet convallis, porttitor magna ullamcorper, amet egestas mauris. Ut magna finibus nisi nec lacinia. Nam maximus erat id euismod egestas. Pellentesque sapien ac quam. Lorem ipsum dolor sit nullam.</p>
</footer>
</body>
</html>
there is a box with text, at the right of the box there is an image
The box of text is have z index higher than image, so box of text look like in front of image
I used text-align center, to center all components inside div, and this is a must
Now I want the only text, only the text in box of text is align left
How can I achieve this?
.button-yellow, .button-red {
font: 16px AdobeCaslonPro;
text-decoration: none;
padding: 6px 12px 6px 12px;
border-right: 1px solid #333333;
border-bottom: 1px solid #333333;
border-radius: 4px;
moz-border-radius: 4px;
webkit-border-radius: 4px;
font-style: italic;
}
.button-yellow {
background-color: #ccb96b;
color: #430615;
}
.button-red {
background-color: #430615;
color: #ccb96b;
margin-top: -20px;
}
#section-welcome-content {
text-align: center;
}
#welcome-content{
width: 45%;
margin: 0 0 0 0 ;
}
#welcome-content-inner {
background-color: #ccb96b;
color: #430615;
padding: 50px;
z-index: 10;
position: relative;
}
#welcome-content p{
}
#crop {
width: 600px;
height: 500px;
overflow: hidden;
margin: 0 0 0 -50px ;
}
#crop img {
width: 800px;
height: 600px;
margin: -75px 0 0 -100px;
z-index: 1;
}
<section id="section-welcome-content" class="pad">
<div id="welcome-content" style=" display: inline-block; " >
<div id="welcome-content-inner" >
<p>
<h3 style="font-size: 1.5em; text-transform: uppercase;"> <i>Lorem ipsum</i> </h3>
Lorem ipsum dolor sit amet, consectetur adipiscing elit. Mauris arcu sapien, dignissim id laoreet quis, sollicitudin sed dui. Mauris mauris ligula, hendrerit sed ligula vitae, viverra auctor eros. Duis rutrum dolor a felis elementum, eu facilisis justo sollicitudin.
<br><br>
Lorem ipsum dolor sit amet, consectetur adipiscing elit. Mauris arcu sapien, dignissim id laoreet quis, sollicitudin sed dui. Mauris mauris ligula, hendrerit sed ligula vitae, viverra auctor eros. Duis rutrum dolor a felis elementum, eu facilisis justo sollicitudin.
<br><br><br>
Read more
</p>
</div>
<div>
</div>
<div>
</div>
</div>
<div id="crop" style=" display: inline-block; ">
<img src="http://media.caranddriver.com/images/media/51/2017-10best-lead-photo-672628-s-original.jpg" alt="" style=" "/>
</div>
</section>
Any help appreciated
My answer comprises of 2 scenarios so it can help you the way you want. So you can choose the best way you want. I have also included live example so you can easily check it .
1. For all text inside to be on left, which includes both heading and text. Add this css
/* For All Left */
#welcome-content-inner {
text-align: left;
}
.button-yellow,
.button-red {
font: 16px AdobeCaslonPro;
text-decoration: none;
padding: 6px 12px 6px 12px;
border-right: 1px solid #333333;
border-bottom: 1px solid #333333;
border-radius: 4px;
moz-border-radius: 4px;
webkit-border-radius: 4px;
font-style: italic;
}
.button-yellow {
background-color: #ccb96b;
color: #430615;
}
.button-red {
background-color: #430615;
color: #ccb96b;
margin-top: -20px;
}
#section-welcome-content {
text-align: center;
}
#welcome-content {
width: 45%;
margin: 0 0 0 0;
}
#welcome-content-inner {
background-color: #ccb96b;
color: #430615;
padding: 50px;
z-index: 10;
position: relative;
}
#welcome-content p {}
#crop {
width: 600px;
height: 500px;
overflow: hidden;
margin: 0 0 0 -50px;
}
#crop img {
width: 800px;
height: 600px;
margin: -75px 0 0 -100px;
z-index: 1;
}
/* For All Left */
#welcome-content-inner {
text-align: left;
}
<section id="section-welcome-content" class="pad">
<div id="welcome-content" style=" display: inline-block; ">
<div id="welcome-content-inner">
<p>
<h3 style="font-size: 1.5em; text-transform: uppercase;"> <i>Lorem ipsum</i> </h3>
Lorem ipsum dolor sit amet, consectetur adipiscing elit. Mauris arcu sapien, dignissim id laoreet quis, sollicitudin sed dui. Mauris mauris ligula, hendrerit sed ligula vitae, viverra auctor eros. Duis rutrum dolor a felis elementum, eu facilisis justo
sollicitudin.
<br><br> Lorem ipsum dolor sit amet, consectetur adipiscing elit. Mauris arcu sapien, dignissim id laoreet quis, sollicitudin sed dui. Mauris mauris ligula, hendrerit sed ligula vitae, viverra auctor eros. Duis rutrum dolor a felis elementum,
eu facilisis justo sollicitudin.
<br><br><br>
Read more
</p>
</div>
<div>
</div>
<div>
</div>
</div>
<div id="crop" style=" display: inline-block; ">
<img src="http://media.caranddriver.com/images/media/51/2017-10best-lead-photo-672628-s-original.jpg" alt="" style=" " />
</div>
</section>
2. For only text to be on left and heading on center. Add this css.
/* For only text Left and heading center */
#welcome-content-inner {
text-align: left;
}
#welcome-content-inner h3 {
text-align: center;
}
.button-yellow,
.button-red {
font: 16px AdobeCaslonPro;
text-decoration: none;
padding: 6px 12px 6px 12px;
border-right: 1px solid #333333;
border-bottom: 1px solid #333333;
border-radius: 4px;
moz-border-radius: 4px;
webkit-border-radius: 4px;
font-style: italic;
}
.button-yellow {
background-color: #ccb96b;
color: #430615;
}
.button-red {
background-color: #430615;
color: #ccb96b;
margin-top: -20px;
}
#section-welcome-content {
text-align: center;
}
#welcome-content {
width: 45%;
margin: 0 0 0 0;
}
#welcome-content-inner {
background-color: #ccb96b;
color: #430615;
padding: 50px;
z-index: 10;
position: relative;
}
#welcome-content p {}
#crop {
width: 600px;
height: 500px;
overflow: hidden;
margin: 0 0 0 -50px;
}
#crop img {
width: 800px;
height: 600px;
margin: -75px 0 0 -100px;
z-index: 1;
}
/* For only text Left and heading center */
#welcome-content-inner {
text-align: left;
}
#welcome-content-inner h3 {
text-align: center;
}
<section id="section-welcome-content" class="pad">
<div id="welcome-content" style=" display: inline-block; ">
<div id="welcome-content-inner">
<p>
<h3 style="font-size: 1.5em; text-transform: uppercase;"> <i>Lorem ipsum</i> </h3>
Lorem ipsum dolor sit amet, consectetur adipiscing elit. Mauris arcu sapien, dignissim id laoreet quis, sollicitudin sed dui. Mauris mauris ligula, hendrerit sed ligula vitae, viverra auctor eros. Duis rutrum dolor a felis elementum, eu facilisis justo
sollicitudin.
<br><br> Lorem ipsum dolor sit amet, consectetur adipiscing elit. Mauris arcu sapien, dignissim id laoreet quis, sollicitudin sed dui. Mauris mauris ligula, hendrerit sed ligula vitae, viverra auctor eros. Duis rutrum dolor a felis elementum,
eu facilisis justo sollicitudin.
<br><br><br>
Read more
</p>
</div>
<div>
</div>
<div>
</div>
</div>
<div id="crop" style=" display: inline-block; ">
<img src="http://media.caranddriver.com/images/media/51/2017-10best-lead-photo-672628-s-original.jpg" alt="" style=" " />
</div>
</section>
You just need to add text-align:left; in your welcome-content-inner div and you're there.
.button-yellow, .button-red {
font: 16px AdobeCaslonPro;
text-decoration: none;
padding: 6px 12px 6px 12px;
border-right: 1px solid #333333;
border-bottom: 1px solid #333333;
border-radius: 4px;
moz-border-radius: 4px;
webkit-border-radius: 4px;
font-style: italic;
}
.button-yellow {
background-color: #ccb96b;
color: #430615;
}
.button-red {
background-color: #430615;
color: #ccb96b;
margin-top: -20px;
}
#section-welcome-content {
text-align: center;
}
#welcome-content{
width: 45%;
margin: 0 0 0 0 ;
}
#welcome-content-inner {
background-color: #ccb96b;
color: #430615;
padding: 50px;
z-index: 10;
position: relative;
text-align: left;
}
#welcome-content p{
}
#crop {
width: 600px;
height: 500px;
overflow: hidden;
margin: 0 0 0 -50px ;
}
#crop img {
width: 800px;
height: 600px;
margin: -75px 0 0 -100px;
z-index: 1;
}
<section id="section-welcome-content" class="pad">
<div id="welcome-content" style=" display: inline-block; " >
<div id="welcome-content-inner" >
<p>
<h3 style="font-size: 1.5em; text-transform: uppercase;"> <i>Lorem ipsum</i> </h3>
Lorem ipsum dolor sit amet, consectetur adipiscing elit. Mauris arcu sapien, dignissim id laoreet quis, sollicitudin sed dui. Mauris mauris ligula, hendrerit sed ligula vitae, viverra auctor eros. Duis rutrum dolor a felis elementum, eu facilisis justo sollicitudin.
<br><br>
Lorem ipsum dolor sit amet, consectetur adipiscing elit. Mauris arcu sapien, dignissim id laoreet quis, sollicitudin sed dui. Mauris mauris ligula, hendrerit sed ligula vitae, viverra auctor eros. Duis rutrum dolor a felis elementum, eu facilisis justo sollicitudin.
<br><br><br>
Read more
</p>
</div>
<div>
</div>
<div>
</div>
</div>
<div id="crop" style=" display: inline-block; ">
<img src="http://media.caranddriver.com/images/media/51/2017-10best-lead-photo-672628-s-original.jpg" alt="" style=" "/>
</div>
</section>
Hope it helps.
There's a problem in my code attached below:
The img with id listItemProfile stays always in middle no matter what padding I set, I though it might due to there's some padding in its parent, but I couldn't find any, any thoughts?
Thanks in advance!
<!DOCTYPE html>
<html>
<head>
</head>
<style type="text/css">
.accordionOm {
position: relative;
padding: 10px 0 10px 30px;
margin: 0;
font: 300 18px 'Oswald', Arial, Helvetica, sans-serif;
cursor: pointer;
}
.accordionOm:hover {
color: #000;
}
.accordionOm:before,
.accordionOm:after {
content: "";
position: absolute;
background: #333;
display: inline-block;
}
.accordionOm:before {
width: 20px;
height: 2px;
left: 0;
top: 22px;
}
.accordionOm:after {
width: 2px;
height: 20px;
left: 9px;
top: 13px;
transition: transform .5s;
transform: rotate(0);
}
.accordionOm.opened:after {
transform: rotate(90deg);
}
.accordionOm + div {
border-left: 4px solid #999;
padding: 0 15px;
margin-left: 8px;
font: 13px 'Open Sans', Arial, Helvetica, sans-serif;
color: #666;
}
* {
font-family: Arial, Verdana, sans-serif;
color: #665544;
text-align: center;}
body {
width: 100%;
margin: 0 auto;
}
#trailBar{
margin-left: 35px;
margin-right: 35px;
margin-top: 25px;
margin-bottom: 25px;
height: 180px;
background: -webkit-linear-gradient(right, #31a7de, #31a7de 35px, white 35px, white);
border: transparent;
border-radius:0.25em;
}
p.trailTextTop{
padding-top: 25px;
padding-left: 25px;
padding-right: 60px;
padding-bottom: 25px;
font-size: large;
}
p.trailTextBot{
padding-left: 25px;
padding-right: 60px;
padding-bottom: 25px;
font-size: large;
}
.left { float: left; }
.right { float: right; }
p { overflow: hidden; }
.panel-group .list-group {
margin-bottom: 0;
}
.panel-group .list-group .list-group-item {
border-radius: 0;
border-left: none;
border-right: none;
}
.panel-group .list-group .list-group-item:last-child {
border-bottom: none;
}
.panel-body{
background: #efefef;
}
#listItem{
position: relative;
height: 200px;
background: #efefef;
}
#listItemProfile{
position: absolute;
height: 80px;
width: 80px;
padding-top: 60px;
padding-bottom: 60px;
padding-left: 35px;
}
#listItemTitle{
}
#listItemSubtitle{
}
#listItemInfo{
}
#listItemArrow{
}
</style>
<body>
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script>
<h4 class="accordionOm opened">
<div id="listItem">
<img id = "listItemProfile" src="images/Portrait.png">
<div id="listItemTitle">
</div>
<div id="listItemSubtitle">
</div>
<div id="listItemInfo">
</div>
<div id="listItemArrow">
</div>
</div>
</h4>
<div>
<div id="trailBar">
<p class="trailTextTop"><span class='left'>Good morning, I just start my first day trip. Happy pedal!</span></p>
<p class="trailTextBot"><span class='left'>Time 7:20</span><span class='right'>45 Miles</span></p>
</div>
<div id="trailBar">
<p class="trailTextTop"><span class='left'>Good morning, I just start my first day trip. Happy pedal!</span></p>
<p class="trailTextBot"><span class='left'>Time 7:20</span><span class='right'>45 Miles</span></p>
</div>
<div id="trailBar">
<p class="trailTextTop"><span class='left'>Good morning, I just start my first day trip. Happy pedal!</span></p>
<p class="trailTextBot"><span class='left'>Time 7:20</span><span class='right'>45 Miles</span></p>
</div>
</div>
<h4 class="accordionOm">Accordian heading</h4>
<div>
<p>Lorem ipsum dolor sit amet, adipiscing elit. Nullam dignissim convallis est. Quisque aliquam. Donec faucibus. Nunc iaculis suscipit dui. Nam sit amet sem. Aliquam libero nisi, imperdiet at, tincidunt nec, gravida vehicula, nisl. Praesent mattis, massa
quis luctus fermentum, turpis mi volutpat justo, eu volutpat enim diam eget metus.</p>
</div>
<h4 class="accordionOm">Accordian heading</h4>
<div>
<p>Lorem ipsum dolor sit amet, adipiscing elit. Nullam dignissim convallis est. Quisque aliquam. Donec faucibus. Nunc iaculis suscipit dui. Nam sit amet sem. Aliquam libero nisi, imperdiet at, tincidunt nec, gravida vehicula, nisl. Praesent mattis, massa
quis luctus fermentum, turpis mi volutpat justo, eu volutpat enim diam eget metus.</p>
</div>
<h4 class="accordionOm">Accordian heading</h4>
<div>
<p>Lorem ipsum dolor sit amet, adipiscing elit. Nullam dignissim convallis est. Quisque aliquam. Donec faucibus. Nunc iaculis suscipit dui. Nam sit amet sem. Aliquam libero nisi, imperdiet at, tincidunt nec, gravida vehicula, nisl. Praesent mattis, massa
quis luctus fermentum, turpis mi volutpat justo, eu volutpat enim diam eget metus.</p>
</div>
</body>
<script>
$('.accordionOm').next().hide();
$(".opened").next().show();
$('.accordionOm').click(function() {
if ($(this).hasClass("opened") == true) {
$(this).next().slideUp("slow");
$(this).removeClass('opened');
} else {
$(".opened").next().slideUp("slow");
$(".opened").removeClass("opened");
$(this).addClass('opened');
$(this).next().slideDown("slow");
}
});
</script>
</html>
Hi now define this css
#listItemProfile {
position: absolute;
height: 80px;
width: 80px;
/* padding-top: 60px; */
/* padding-bottom: 60px; */
/* padding-left: 35px; */
left: 50%;
top: 50%;
margin-left: -40px; // your total width img / 2
margin-top: -40px; // your total height img /2
}
You can use this css given below :
#listItemProfile {
position: absolute;
height: 80px;
width: 80px;
left: 50%;
top: 50%;
margin-left: -40px;
margin-top: -40px;
}
try with margin-left , margin-right
Example
.class-name{
margin-left:10px;
margin-right:50px;
}