HTML elements wont pin to the right - html

Ive just been practicing using HTML and CSS and I've ran into an issue. I want this (the objects in the blue square) to be on the right but it goes underneath everything else for some reason. How can I fix it? Here is what I have tried:
HTML:
<div class="status-post row">
<div class="post-meta col-xs">
<center>
<img src="./testpost.png" alt/>
<p>
"This is a test status... Test. Test. Test."
</p>
</center>
</div>
<div class="post-interact col-xs-2">
<a href="#" class="vote voteup">
<img src="./img/global/upvote.png" alt/>
</a>
<span id="picidhere" class="count">100</span>
<a href="#" class="vote report">
<img src="./img/global/report.png" alt/>
</a>
</div>
</div>
CSS:
#appbody .status-post {
position: relative;
background: #76ac8b;
min-height: 300px;
padding: 25px;
margin-bottom: 25px;
opacity: 0.5;
}
#appbody .status-post .post-meta {
margin-bottom: 25px;
}
#appbody .status-post .post-meta img {
margin-left: auto;
margin-right: auto;
}
#appbody .status-post .post-meta p {
text-align: center;
font-size: 20px;
clear: both;
color: #FFF;
font-family: "Arvo";
}
#appbody .status-post .post-interact {
text-align: center;
margin: 0 auto;
height: 100%;
padding-right: 0px;
padding-left: 0px;
position: relative;
top: 50%;
transform: translateY(30%);
vertical-align: middle;
}
#appbody .status-post .post-interact .vote {
background-repeat: no-repeat;
background-position: center center;
width: 100%;
height: 20px;
display: block;
}
#appbody .status-post .post-interact .report {
background-repeat: no-repeat;
background-position: center center;
width: 100%;
height: 26px;
display: block;
padding-top: 12px;
}
#appbody .status-post .post-interact .count {
font-size: 25px;
color: #FFF;
display: block;
font-family: "Arvo";
padding-top: 9px;
padding-bottom: 9px;
}

#appbody .status-post .post-interact {
position: absolute;
top: 10px;
right: 10px
}
use absolute positioning to place the element
EDIT
Check this demo to understand absolute positioning
http://jsfiddle.net/jja27pce/

Just like the others have said, you need to make your content positioned absolutely, and then position then to the top right.
Code like this should work:
.post-interact {
position: absolute;
top: 0px;
right: 0px
}

Please add below css
.post-interact {
position:absolute !important;
top:0 !important;
right:0 !important;
}
into bottom of your css.

Related

CSS trouble to place buttom border under logos top right of the page

I'm trying to put a border under my logos at the top of the page right.
Before I'm adding position:absolute; to the div, my 2 logos are placed where I want them to be under the contact me top right. But the border on the left side of the page, when I put position:absolute; it moves but the logos jump down the page.
css #para {
margin-right: 1.66%;
float: right;
font-family: indie flower;
position: absolute;
top: 0px;
right: 0px;
}
.fb {
width: 27px;
float: right;
right: 5px;
position: absolute;
margin-top: 3px;
top: 35px;
}
#in {
margin-top: 4px;
width: 25px;
float: right;
position: absolute;
right: 40px;
top: 35px;
}
div {
border-bottom: 1.5px solid red;
width: 60px;
right: 5px;
position: absolute;
}
<p id="para">Contact me </p>
<div>
<img class="fb" width="10" src="https://cdn3.iconfinder.com/data/icons/picons-social/57/46-facebook-512.png">
<img id="in" width="25" src="https://image.flaticon.com/icons/png/512/69/69366.png">
</div>
Just use float: right on your #para and div. Use a <span> with clear attribute to prevent div from overlapping. No need for any absolute positioning. As you can see this simplifies the code a lot.
.clear {
display: block;
clear: both;
}
PS: Avoid adding CSS to tags like div.
#para {
margin-right: 1.66%;
float: right;
font-family: indie flower;
}
.clear {
display: block;
clear: both;
}
.fb {
width: 27px;
margin-top: 3px;
}
#in {
margin-top: 4px;
width: 25px;
}
#icons {
float: right;
border-bottom: 1.5px solid red;
width: 60px;
}
<p id="para">Contact me </p>
<span class="clear"></span>
<div id="icons">
<img class="fb" src="https://cdn3.iconfinder.com/data/icons/picons-social/57/46-facebook-512.png">
<img id="in" src="https://image.flaticon.com/icons/png/512/69/69366.png">
</div>
From the snippet you have posted, it looks like it may be because you are positioning the icons absolute while not moving the container (which has the border).
I would recommend the below. I have removed the absolute positioning from the icons, along with the floats, and instead have positioned the icon container.
css #para {
margin-right: 1.66%;
float: right;
font-family: indie flower;
position: absolute;
top: 0px;
right: 0px;
}
.fb {
width: 27px;
margin-top: 3px;
}
#in {
margin-top: 4px;
width: 25px;
}
.icon-container {
border-bottom: 1.5px solid red;
width: 60px;
right: 5px;
top: 0px;
position: absolute;
}
<p id="para">Contact me </p>
<div class="icon-container">
<img class="fb" width="10" src="https://cdn3.iconfinder.com/data/icons/picons-social/57/46-facebook-512.png">
<img id="in" width="25" src="https://image.flaticon.com/icons/png/512/69/69366.png">
</div>
Check This out. And one thing style elements by class not id
#left {
margin-right: 1.66%;
float: left;
font-family: indie flower;
top: 0px;
right: 0px;
}
.fb {
width: 27px;
}
#in {
width: 25px;
}
#right {
float: right;
text-align: center;
border-bottom: 1.5px solid red;
right: 5px;
}
<!DOCTYPE html>
<html>
<head>
<title>question reality.</title>
<link rel="stylesheet" type="text/css" href="style.css">
</head>
<body>
<div id="right">
<p>Contact me </p>
<img id="in" width="25" src="https://image.flaticon.com/icons/png/512/69/69366.png">
<img class="fb" width="10" src="https://cdn3.iconfinder.com/data/icons/picons-social/57/46-facebook-512.png">
</div>
</body>
</html>

Absolute element not placing over relative element

Within my header, I am trying to place pending-button-notification over theimages-cart image. For some reason, the pending-button-notification div is showing on the left side of the header div.
Does anyone see why this isn't placing correctly?
This is the problematic code:
<div id="pending-order-button">
<a href="pendingOrders.html"><img src="images/cart.png" class="header-buttons" alt="Car">
<div id="pending-button-notification"></div>
</a>
</div>
header {
width: 100%;
max-width: 100%;
height: 100px;
position: relative;
border-bottom: 1px solid #E5E5E5;
}
#header-wrap {
width: 90%;
height: 100%;
margin: auto 5%;
}
#header-logo {
width: 200px;
height: auto;
position: absolute;
top: 50%;
transform: translateY(-50%);
}
.header-buttons {
width: 30px;
height: auto;
float: right;
margin: 30px 40px 0 50px;
cursor: pointer;
}
.header-buttons:first-child {
margin-right: 0;
}
#pending-order-button {
position: relative;
}
#pending-button-notification {
border-radius: 15px;
background: #09afdf;
height: 25px;
width: 25px;
position: absolute;
color: #FFF;
font-size: 1.3rem;
top: 5px;
left: 5px;
text-align: center;
}
<header>
<div id="header-wrap">
Logo
<img src="images/menu.png" class="header-buttons" alt="Pending Orders">
<div id="pending-order-button">
<a href="pendingOrders.html"><img src="images/cart.png" class="header-buttons" alt="Car">
<div id="pending-button-notification"></div>
</a>
</div>
</div>
</header>
It's your float:right on .header-buttons which is causing the problem.
I suggest that you remove that and float the #pending-order-button div instead so that it and all it's content is moved to the right.
#pending-order-button {
position: relative;
float:right;
}

I'm having trouble making a button

I'm practicing my HTML by making a website, and I'm making a header with buttons.
I'm trying to make the button the full height of the header, but it's going out of the header for some reason, and not going to the top.
#header {
background-color: #1564B3;
color: #fff;
height: 70px;
position: fixed;
width: 100%;
top: 0%;
left: 0%;
}
#header-a {
width: 100px;
background-color: #555555;
display: inline-block;
text-align: center;
margin-top: 0px;
height: 100%;
}
#header-h {
display: inline-block;
margin-top: 20px;
}
<div id="header">
<h2 id="header-h">Header text</h2>
<div id="header-a">
Home
</div>
</div>
You can reset the vertical-align(defaut is baseline) value on inline-block elements whenever needed. here vertical-align:top; will do fine :
#header {
background-color: #1564B3;
color: #fff;
height: 70px;
position: fixed;
width: 100%;
top: 0%;
left: 0%;
}
#header-a {
width: 100px;
background-color: #555555;
display: inline-block;
text-align: center;
margin-top: 0px;
height: 100%;
vertical-align:top;
}
#header-h {
display: inline-block;
margin-top: 20px;
}
<div id="header">
<h2 id="header-h">Header text</h2>
<div id="header-a">
Home
</div>
</div>
For a to cover the div, you may also use height or eventually line-height:
#header {
background-color: #1564B3;
color: #fff;
height: 70px;
position: fixed;
width: 100%;
top: 0%;
left: 0%;
}
#header-a {
width: 100px;
background-color: #555555;
display: inline-block;
text-align: center;
margin-top: 0px;
height: 100%;
vertical-align:top;
}
#header-a a {
display:block;
line-height:70px;/* will size it up to 70px height for each line */
}
#header-h {
display: inline-block;
margin-top: 20px;
}
<div id="header">
<h2 id="header-h">Header text</h2>
<div id="header-a">
Home
</div>
</div>
I changed it to this code. What I did was to change the display to block (in both header-a and header-h) instead of inline-block. I then floated both elements left. Run the snippet to see it in action
#header {
background-color: #1564B3;
color: #fff;
height: 70px;
position: fixed;
width: 100%;
top: 0%;
left: 0%;
}
#header-a {
width: 100px;
background-color: #555555;
text-align: center;
margin-top: 0px;
height: 100%;
}
#header-h {
margin-top: 20px;
}
#header-h,
#header-a {
display: block;
float: left;
}
<div id="header">
<h2 id="header-h">Header text</h2>
<div id="header-a">
Home
</div>
</div>
Rather than setting the height of your menu bar to 70px, you could let the contents within the menu bar size its height. That way you can vertically centre the Home button. JSFiddle
HTML
<div id="header">
<h2 id="header-h">Header text</h2>
<div id="header-a">
Home
</div>
</div>
CSS
#header {
position: fixed;
background-color: #1564B3;
color: #fff;
width: 100%;
top: 0%;
left: 0%;
}
#header-a {
background-color: #555555;
display:inline-block;
padding:30px 50px 30px 50px;
width:10%;
text-align:center;
}
#header-h {
display:inline-block;
width:30%;
text-align:center;
}
Do you see how the padding of #header-a not only vertically centres the Home text but also how the #header sizes to fit it.

Images move on zoom in, but stay on zoom out

I am making a site for a school project. Everything was going well until I zoomed my creation, the facebook icon and map hyperlink started moving left, their position didn't seem a problem on zooming out since they were exactly as they had to be. My code is clumsy written, I've just started learning CSS so please leave a negative response.
CSS:
body {
background-image: url("backgr.jpg");
background-size: cover;
overflow-x: hidden;
}
.site {
background-image: url("repet.jpg");
background-position: center top;
background-repeat: repeat-x;
}
.all {
position: relative;
}
.lin {
display: block;
margin-left: auto;
margin-right: auto;
}
.fc {
position: absolute;
height: 50px;
width: 50px;
margin: 0 auto;
left: 300px;
right: 0;
top: 55%;
}
.map1 {
position: absolute;
text-decoration: underline;
font-family: "Myriad-Pro", Calibri;
letter-spacing: -0.05em;
font-style: condensed;
font-size: 130%;
color: white;
left: 85px;
text-align: center;
width: 100%;
top: 53.2%;
}
.map2 {
position: absolute;
text-decoration: underline;
font-family: "Myriad-Pro", Calibri;
letter-spacing: -0.05em;
font-style: condensed;
font-size: 130%;
color: white;
left: 80px;
text-align: center;
width: 100%;
top: 70%;
}
HTML
<div class="all">
<a href="https://www.facebook.com/MumbaiIndianStruma31Burgas/?fref=ts">
<img src="fc.png" class="fc">
</a>
<a class="map1" href="https://www.google.bg/maps/place/Mumbai+Indian+Restaurant/#42.5047587,27.4665381,17z/data=!3m1!4b1!4m2!3m1!1s0x40a69490c9140d5d:0xe145b9d1e18c51ee">
Карта
</a>
<a class="map2" href="https://www.google.bg/maps/place/Mumbai+Indian+Restaurant/#42.5047587,27.4665381,17z/data=!3m1!4b1!4m2!3m1!1s0x40a69490c9140d5d:0xe145b9d1e18c51ee">
Map
</a>
<div class="site">
<img src="line.jpg" class="lin">
</div>
</div>
Fiddle demo
You can use Padding left, Padding Right and margin option to set the image

Can't remove padding in footer

My footer seems as though it has some type of imaginary (Unwanted padding in the top of the footer div... If you need an example of what I mean just visit my site) padding to it. If you view my sample link you will see what I am referring to.
<div id="footer">
<div id="Social">
<img src="img/Follow.png" width="339" height="21" alt="Follow on Social" style="position: relative; display:block;" />
<ul>
<li class="Twitter">Twitter</li>
<li class="Facebook">Facebook</li>
<li class="Youtube">Youtube</li>
<li class="Linkdin">Linkdin</li>
</ul>
</div> <!-- Social -->
<div style="clear:both"></div>
</div> <!-- footer -->
My CSS:
#footer {
background-image:url(img/FooterBG.png);
height: 92px;
position: relative;
z-index: 10;
padding: 0 35px;
left: 0px;
top: 82px;
}
#Social {
float: left;
width: 339px;
}
/* Social Links */
.Twitter a {
background-image: url(http://www.nerissagrigsby.com/wp-content/themes/twentytwelve/img/Twitter.png);
overflow: hidden;
text-indent: -999px;
display: block;
width: 42px;
height: 27px;
}
.Twitter a:hover {
background-position-y: 27px;
}
.Facebook a {
background-image: url(http://www.nerissagrigsby.com/wp-content/themes/twentytwelve/img/Facebook.png);
overflow: hidden;
text-indent: -999px;
display: block;
width: 18px;
height: 31px;
}
.Facebook a:hover {
background-position-y: 31px;
}
.Youtube a {
background-image: url(http://www.nerissagrigsby.com/wp-content/themes/twentytwelve/img/YouTube.png);
overflow: hidden;
text-indent: -999px;
display: block;
width: 29px;
height: 30px;
}
.Youtube a:hover {
background-position-y: 30px;
}
.Linkdin a {
background-image: url(http://www.nerissagrigsby.com/wp- content/themes/twentytwelve/img/LinkedIn.png);
overflow: hidden;
text-indent: -999px;
display: block;
width: 28px;
height: 29px;
}
.Linkdin a:hover {
background-position-y: 29px;
}
#Social ul li {
display: inline-block;
margin-right: 24px;
}
#Social ul {
margin: 12px 0 0 0;
padding: 0;
}
How can I remove this padding?
Get rid of top: 82px;
#footer {
background-image:url(img/FooterBG.png);
height: 92px;
position: relative;
z-index: 10;
padding: 0 35px;
left: 0px;
/* top: 82px; */
}
You could try using a css reset
You could also try using:
<meta http-equiv="X-UA-Compatible" content="IE=edge">
Just in case it's an internet explorer problem.
#Herbert Peters I didn't got why that imaginary boundary is there. But, if you remove
<div style="clear:both"></div>
then it will not be there.
Just put margin/padding to 0 or a negative value (try -1 and then increase until its gone) for the wanted direction