Managing and positioning CSS <divs> - html

I am trying to achieve this:
...as a format for news articles on my site (runic-paradise.com). You can see I've achieved everything except the orange bits. I'm trying to make the orange bits their own divs so I can put them in colored square backgrounds - to resemble something like this:
...however, I can't seem to get the divs to do what I want. It ends up messing up the 2 lower divs holding the image and text content. Anyone have any quick tips on how to achieve this? :(
JSFiddle of what I have so far:
http://jsfiddle.net/HDbq6/1/
HTML:
<div class="articleshell">
<div class="articletitle">
<h4 class="newstitleh4">A shining beacon in the desert - November 5, 2013</h4>
</div>
<div class="articleauthor">
Author
</div>
<div class="articleimg">
<img src="images/thumbs/EukitoDesertTempleThumb.jpg" width="90" height="90" class="news_thumb" alt="Eukito's Desert Temple" />
</div>
<div class="articletext">
<p>Eukito has completed construction of his desert temple. Of course no temple is complete without a secret passage or two... Stop on by at night to see it shining in the desert!</p>
</div>
</div>
CSS
.articleshell {
width: 770px;
max-height: none;
min-height: 130px;
padding-top: 5.px;
padding-right: 5.px;
padding-bottom: 5.px;
padding-left: 5.px;
padding-top: 1px;
padding-right: 5px;
padding-bottom: 5px;
padding-left: 5px;
background-color: #564D4D;
}
.articletext {
padding-right: 10px;
padding-bottom: 10px;
padding-left: 10px;
clear: both;
}
.articleimg {
float: left;
margin-right: 15px;
margin-bottom: 5px;
width: 90px;
height: 90px;
margin-left: 5px;
clear: both;
}
.articletitle {
margin-bottom: 5px;
margin-left: 5px;
margin-right: 5px;
margin-top: 3px;
float: left;
}
.newstitleh4 {
margin-bottom: 2px;
margin-top: 2px;
}
.articleauthor {
float: left;
text-align: right;
}
.articlecontent {
clear: both;
}

Something like this ?
fiddle
.main{width:500px; height:200px; border:1px solid #ccc; background:#f3f3f3; padding:5px;}
#title{width:45%; background:#ccc; border:1px solid #333; display: inline-block;}
.buttons{width:15%; background:orange; display: inline-block; border:1px solid #333;}
.mainContent{ width:100%; color:#ccc; border:1px solid #333; margin-top:5px; height:170px;}
<div class="main">
<div id="title">Title</div>
<div class="buttons">Author</div>
<div class="buttons">Role</div>
<div class="buttons">Date</div>
<div class="mainContent"></div>
</div>
The title id have a display:inline-block and div to get the thumb and the text content, that way the "buttons" don't mess up with the content. (I think)

Related

Clearfix is not working showing profile at right

I have a simple web page there I am using clearfix fix as below
.clearfix:after{
content: "";
display: :table;
clear:both;
}
I have create code https://jsfiddle.net/xrcwrn/7b26pwsd/1/
I want to show profile below but it is showing at right
You can try to wrap all of the items which have float property with a div.clearfix. Like this:
*{
margin:0;
padding:0;
box-sizing: border-box;
}
body{
font-family: halvitica ,Arial;
font-size: 18px;
}
.container{
width:1140px;
margin-left: auto;
margin-right: auto;
margin-top:20px;
}
h1,h2{
color:green;
}
h1{
font-size: 40px;
}
h2{
font-size: 35px;
}
p{
text-align: justify
}
.blog-post{
width: 75%;
float: left;
padding-right: 30px;
}
.other-post{
width: 25%;
float:left;
}
.author-box{
padding-top: 20px;
border-top: 1px solid green;
}
.author-box img{
height: 100px;
width: 100px;
border-radius: 50%;
}
.clearfix:after{
content: "";
display: :table;
clear:both;
}
.other {
margin-bottom: 40px;
}
.author-text {
float: left;
margin-left: 25px;
}
<link rel="stylesheet" href="https://stackpath.bootstrapcdn.com/bootstrap/4.4.1/css/bootstrap.min.css" />
<div class="container">
<div class="clearfix">
<div class="blog-post">
<h2>He share of first to worse</h2>
<p>
Conveying or northward offending admitting perfectly my. Colonel gravity get thought fat smiling add but. Wonder twenty hunted and put income set desire expect. Am cottage calling my is mistake cousins talking up. Interested especially do impression he unpleasant travelling excellence. All few our knew time done draw ask.
</p>
</div>
<div class="other-post">
<div class="other">Post 1</div>
<div class="other">Post 2</div>
<div class="other">Post 3</div>
</div>
</div>
<div class="author-box">
<image src="https://randomuser.me/api/portraits/men/68.jpg" alt="author"/>
<p class="author-text">Neeta Rai</p>
</div>
</div>

Positioning a Price Circle on an image using CSS

I think this is probably a simple thing to do but when i try to do it it messes other stuff up that I've got.
Basically I am using php in codeigniter. I have a for loop that displays lots of product items (tours) to the user to choose and enter all the specific details related to that product. This page is here:
http://eternalcitytours.com/en/2/Catholic-Tours-Of-Rome-Italy
On each product box there is a blue ring.
I want to substitute the yellow price circle (see example below)
http://eternalcitytours.com/en/22/Tours/Ancient-Coliseum-Roman-Forum-Rome-Tour
to be instead of this blue ring. However every time I do it everything messes up.
The relevant bits of code are:
.feature li .thumb .date {
position: absolute;
bottom: -25px;
left: 110px;
display: block;
-moz-border-radius: 40px 40px 40px 40px;
-webkit-border-radius: 40px 40px 40px 40px;
border-radius: 40px 40px 40px 40px;
height: 50px;
width: 46px;
background: #f3e4c8;
float: left;
font-family: mensch;
padding-top: 10px;
}
.feature li .thumb .date span {
display: block;
text-align: center;
font-size: 20px;
line-height: 20px;
}
div .raf{
width:16px;
height:16px;
border-radius:50%;
background-color:#CE1126;
background-clip:content-box;
padding:8px;
border:8px solid #00247D;
margin-left:7px;
margin-top:-5px;
}
.tour-price {
font-size: 2.2em;
font-weight: 300;
display: block;
margin-left:auto;
margin-right:auto;
width:60px;
height:60px;
border-radius:50%;
color:#483f34;
line-height:60px;
text-align:center;
background:#ffc55f;
align: center;
}
<ul id="filter-container" class="feature cf" itemscope itemtype="http://schema.org/EventReservation">
<?php
$tcount=count($tours);
$tcount=$tcount-1;
for($i=0; $i<=$tcount;$i++){
echo "
<li class=\"".$tours[$i]['location']."\">
<a href=\"".$tours[$i]['nav_url']."\" class=\"thumb\">".$tours[$i]['img']."
<div class=\"date\"><div class=\"raf\"></div></div>
</a>
<h4 class=\"tour_title\" itemprop=\"name\">".$tours[$i]['title']."</h4>
<div class=\"caption\" itemprop=\"description\">".$tours[$i]['blurb']."</div>
<p><button type=\"button\" class=\"btn btn-primary\">Read More...</button></p>
</li>
";
}?>
</ul>
thanks
TC
Change this code:
div .raf{
width:16px;
height:16px;
border-radius:50%;
background-color:#CE1126;
background-clip:content-box;
padding:8px;
border:8px solid #00247D;
margin-left:7px;
margin-top:-5px;
}
to this one:
div .raf{
margin-top: -15px;
font-size: 2.2em;
font-weight: 300;
display: block;
margin-left: auto;
margin-right: auto;
width: 60px;
height: 60px;
border-radius: 50%;
color: #483f34;
text-align: center;
background: #ffc55f;
}
And I suppose you want also to change the HTML, replace this:
<div class=\"date\"><div class=\"raf\"></div></div>
With this other code:
<div class=\"date\">
<div class=\"raf\" itemprop=\"price\" content=\"43.00\">
<span itemprop=\"priceCurrency\" content=\"EUR\">€</span>
43</div>
</div>
Additional recommendations: You could improve a lot your code readability by correctly formatting your code, see thsi questions: questions questions

floating divs not sitting properly

The problem i am having is the footer div keeps going up behind the the right hand side div. i have a middle containing div with the 2 floated div's side by side and the footer is a separate div not to sure where i have gone wrong here but i have been at it for hours and cant work out the problem.
Here is a js fiddle of what i mean: http://jsfiddle.net/VU3xW/
HTML:
<div id="middlecontainer">
<div id="leftContent">
</div> <!-- end of left content -->
<div id="rightContent">
</div> <!-- end of right content -->
</div> <!-- end of middle container -->
<div id="footer">
<p class="footernav">Home | About | Products | Contact
</p>
<p class="copyright">Copyright © 2013 JBA Packaging Supplies | Designed by iDesign</p>
</div> <!-- end of footer div -->
CSS:
#rightContent{
width: 690px;
height: 400px;
float: right;
background-color:#222;
border-bottom-left-radius: 10px;
border-bottom-right-radius: 10px;
border-top-left-radius: 10px;
border-top-right-radius: 10px;}
#leftContent{
display: inline-block;
width: 240px;
height: 200px;
background-color:#555;
border-bottom-left-radius: 10px;
border-bottom-right-radius: 10px;
border-top-left-radius: 10px;
border-top-right-radius: 10px;}
#middlecontainer {
width: 960px;
background-color:#003;}
#footer {
width: 960px;
background-color: #121212;
text-align: center;
border-bottom-left-radius: 10px;
border-bottom-right-radius: 10px;
border-top-left-radius: 10px;
border-top-right-radius: 10px;}
#footer a{
text-decoration: none;
list-style-type: none;
color:#888;
}
#footer a:hover{
text-decoration: none;
list-style-type: none;
color:#444;
}
.footernav {
font-family:Arial, Helvetica, sans-serif;
font-size: .8em;
color:#444;
padding-top: 10px;}
.copyright {
font-family:Arial, Helvetica, sans-serif;
font-size: .8em;
color:#888;
padding-top: 10px;}
What you are missing is clearing the floating elements
Demo
Just add this <div style="clear: both;"></div> at the end of the container element, you can also clear the floats using overflow: hidden; for the parent div. Also for demo purpose I've added the styles inline, you can make a class out of it and use that instead of inline styles which is considered as bad practices..
Also if you want to clear the floating elements, you can use this to self clear the parent element.
.self_clear:after { /* Use this if you wish to ditch IE8 */
content: " ";
display: table;
clear: both;
}
<div class="self_clear"> <!-- Example usage -->
<div class="floated_left"></div>
<div class="floated_right"></div>
</div>
This answer of mine will provide in detail explanation, that why you need to use clear: both;
Try adding a clearing div
#clear{
clear:both;
}
Here is the fiddle http://jsfiddle.net/swDnn/1/
Hope it helps...
try this
http://jsfiddle.net/VU3xW/4/
#rightContent{
width: 690px;
height: 400px;
float: right;
background-color:#222;
border-bottom-left-radius: 10px;
border-bottom-right-radius: 10px;
border-top-left-radius: 10px;
border-top-right-radius: 10px;}
#leftContent{
display: inline-block;
width: 240px;
height: 200px;
background-color:#555;
border-bottom-left-radius: 10px;
border-bottom-right-radius: 10px;
border-top-left-radius: 10px;
border-top-right-radius: 10px;}
#middlecontainer {
width: 960px;
background-color:#003;}
#footer {
width: 960px;
background-color: #121212;
text-align: center;
border-bottom-left-radius: 10px;
border-bottom-right-radius: 10px;
border-top-left-radius: 10px;
border-top-right-radius: 10px;}
#footer a{
text-decoration: none;
list-style-type: none;
color:#888;
}
#footer a:hover{
text-decoration: none;
list-style-type: none;
color:#444;
}
.footernav {
font-family:Arial, Helvetica, sans-serif;
font-size: .8em;
color:#444;
padding-top: 10px;}
.copyright {
font-family:Arial, Helvetica, sans-serif;
font-size: .8em;
color:#888;
padding-top: 10px;}
Try giving your middlecontainer a overflow:auto property.
Your footer need clearing so add clear:both in #footer
#footer {
clear:both;
width: 960px;
background-color: #121212;
text-align: center;
border-bottom-left-radius: 10px;
border-bottom-right-radius: 10px;
border-top-left-radius: 10px;
border-top-right-radius: 10px;}

Image over flow fix?

I have two columns; first column goes for image and the second holds detail.
My problem is the image over flows to the next line
Adding overflow:auto; or inline-block; to div.portfolioitems_wrap didn't help me
list http://img577.imageshack.us/img577/7002/screenshot20121204at135.png
Maker
<div class="portfolioitems_wrap">
<div class="portfolioitems_column1">first image</div>
</div>
<div class="portfolioitems_column2">information of the institute</div>
<div class="portfolioitems_wrap">
<div class="portfolioitems_column1">first image</div>
</div>
<div class="portfolioitems_column2">information of the institute</div>
<div class="portfolioitems_wrap">
<div class="portfolioitems_column1"><img src="/image/nature.jpg" class="thumbnail" alt="nature" />
</div>
</div>
<div class="portfolioitems_column2">information of the institute
</div>
<div class="portfolioitems_wrap">
<div class="portfolioitems_column1">first image</div>
</div>
<div class="portfolioitems_column2">information of the institute</div>
<div class="clear"></div>
CSS
div.portfolioitems_wrap{
float: left;
width:100%;
color:#555555;
border-bottom: 1px solid #eee;
height: 1.5em;
margin-bottom: 1em;
}
div.portfolioitems_column1{
margin-right: 10px;
}
div.portfolioitems_column2{
float: left;
color:#555555;
width: 300px;
margin-left: -300px;
font-size: 80%;
}
div.portfolioitems_column1 .thumbnail
{
float:left;
margin-right:20px;
border:1px solid #979390;
width:80px;
margin-bottom: 5px;
}
div.clear{
clear: both;
}
Further to my comment above: http://jsfiddle.net/hp7dY/
Just the min-height seems to be enough to fix this
It looks like your DIV organization is a little confused, which is adding to your problem. I'm assuming that the portfolioitems_wrap DIV is supposed to enclose both columns. That said, the problem is more that you're fixing the height of each table row, instead of allowing it to be flexible based on the content.
Removing the height:1.5em; entry from allows your elements to fit in the DIV. You might also consider displaying the column elements as inline-block.
div.portfolioitems_wrap{
float: left;
width:100%;
color:#555555;
border-bottom: 1px solid #eee;
// height: 1.5em;
margin-bottom: 1em;
}
div.portfolioitems_column1{
margin-right: 10px;
display:inline-block;
width:100px;
float:left;
}
div.portfolioitems_column2{
color:#555555;
font-size: 80%;
display:inline-block;
width:300px;
float:left;
}
div.portfolioitems_column1 .thumbnail {
float:left;
border:1px solid #979390;
width:80px;
margin: 0px 10px 5px 10px;
}
div.clear{
clear: both;
}
Here's a working fiddle with some other minor adjustments to make it pretty:
http://jsfiddle.net/72HML/
Hope that helps.

Why won't my elements display horizontally?

I have two sections of my website that should be displaying in a similar manor. One displays correctly, while the other does not. The top one puts each element on its own line, while the bottom puts the above and the two images side by side how I want them.
My two questions are:
1: Why is the broken version broken?
2: What part of the working version is enabling it to display properly (or a better follow up question, what parts of the css are not aiding in it displaying properly and can be deleted?
Broken:
html:
<div id="maintitle">
<span id="chara1"><img src= "<?= $charused ?>" width="150" alt="char2"/></span>
<span id="maintitletext"><h1> Welcome to Born4battle's Wolfenstein 3D page</h1></span>
<span id="chara2"><img src= "<?= $charused ?>" width="150" alt="char2"/></span>
</div>
css:
#maintitle{
color: #ffff00;
text-align: center;
}
#maintitle ul{
margin:0;
padding: 0;
list-style-type: none;
}
#maintitle li{
display: inline;
}
#chara1, #chara2, #maintitletext{
margin-top: 0px;
margin-right: auto;
margin-left: auto;
display: inline;
padding: .5em;
width: 110px;
}
Working:
html:
<div id="share">
<p> Get the official shareware for Wolfenstein 3D and Spear of Destiny below </p>
<span id="getwolf"><img src="http://www.timsooley.com/wolfnow.gif" alt="getwolf"></span>
<span id="getspear"><img src="http://www.timsooley.com/getspear.gif" alt="getspear"></span>
</div>
css:
#share ul{
margin: 0;
padding: 0;
list-style-type: none;
}
#share li{
display:inline;
}
#getspear, #getwolf{
margin-top: 0px;
margin-right: auto;
margin-left: auto;
display: inline;
/*background: #bbbbbb;
border-top: solid 2px #333333;
border-left: solid 2px #333333;
border-right: solid 3px #999999;
border-bottom: solid 3px #999999;*/
padding: .5em;
width: 110px;
}
Please see the Fiddle .
After reading your question what i have understood is that you want your images should be side by side and text should be in middle. in you broken code.
please let me know if i am lagging some where. So i can make changes as per your needs.
see the css rules what i added:
#maintitle{ color: #ffff00; text-align: center; overflow:hidden; width:480px; border:1px solid red; }
#maintitle span { width:148px; display:block; font-size:12px; }
#chara1, #chara2, #maintitletext{ margin-top: 0px; margin-right: auto; margin-left: auto; display: inline; padding: .5em; width: 110px; float:left; // added to make all elements in horizontal manner }
To show the text and images in same line, make these changes in your code:
http://jsfiddle.net/S3CBj/2/
#maintitle{
color: #ffff00;
text-align: center;
}
#maintitle ul{
margin:0;
padding: 0;
}
#chara1, #chara2, #maintitletext{
margin-top: 0px;
margin-right: auto;
margin-left: auto;
display: inline;
float: left;
padding: .5em;
width: 150px;
}​