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
Related
I have two HTML element in one row. Whoch should display something like this:
For that I made both the element display-inline and also I set float left and right respectively. But they are displaying something like this:
You can see they are not being aligned properly.
.selected-account{
display: inline;
float: right;
color: #0679ca;
}
.select-account-accordion{
display: inline;
float: left;
color: #0679ca;
}
<div id="select-account" class="col-sm-12 col-md-12 disabled-billing-accordion">
<h3 id="select-acct" class="select-account-accordion">Select Account(s)</h3>
<span id="account-selected" class="selected-account">0 of 8 account selected</span>
</div>
Can you please suggest on this?
Edit: I think because I put those two element in the div class which I put for creating accordion, so thats why its creating trouble. Please see the style below for that div which is having class "disabled-billing-accordion"
.disabled-billing-accordion h3::before{
background: url("/static/img/accordion.png") no-repeat scroll 0 0
rgba(0, 0, 0, 0);
background-position: -1px -97px;
content: " ";
width: 34px;
height: 34px;
left: 0;
position: absolute;
top: 25px;
margin-left: 1em
}
.disabled-billing-accordion h3{
padding: .2em 0 0 3em;
color: #0679ca;
font-size: 1.5em;
line-height: 2.1875em;
margin-bottom: 8px;
font-weight: 100 !important
}
.disabled-billing-accordion{
padding: 10px;
border-bottom: 1px solid #bdbdbd
}
HI now you can define margin:0; and line-height as like this
.selected-account{
float: right;
color: #0679ca;
margin:0;
line-height:20px;
}
.select-account-accordion{
float: left;
color: #0679ca;
margin:0;
line-height:20px;
}
<div id="select-account" class="col-sm-12 col-md-12 disabled-billing-accordion">
<h3 id="select-acct" class="select-account-accordion">Select Account(s)</h3>
<span id="account-selected" class="selected-account">0 of 8 account selected</span>
</div>
There is margin for h3. Try
#select-acct {
margin: 0;
}
if you use h3 it will take default some margin and line-height if u check in the image while inspect u can see ,reference https://plnkr.co/edit/3O4773wA10jV1tC92zik?p=preview
So u have to add the styles for margin and line-height
.selected-account{
display: inline;
float: right;
color: #0679ca;
margin:0;
line-height:20px;
}
.select-account-accordion{
display: inline;
float: left;
line-height:20px;
margin:0;
}
You can use position:fixed and add left:"width of first one"
Like,
div1{
position:fixed;
width:200px;
height:300px;
}
div2{
position:fixed;
left:200px;
width:200px;
height:300px;
}
Hope it will help.
Edit
I have added some inline css in your code with position:fixed Here is screen shot.
You can simply remove the float: left; property from h3 ie,
.select-account-accordion {
display: inline;
/* float: left; */ //Remove this line
color: #0679ca;
}
Either reduce margin-top: 0px; for
<h3 id="select-acct" class="select-account-accordion">Select Account(s)</h3>
or
add equivalent margin-top example margin-top: 20px for
<span id="account-selected" class="selected-account">0 of 8 account selected</span>
.selected-account{
margin-top: 0px;
display: inline;
float: right;
color: #0679ca;
}
.select-account-accordion{
margin-top: 0px;
display: inline;
float: left;
color: #0679ca;
}
<div id="select-account" class="col-sm-12 col-md-12 disabled-billing-accordion">
<h3 id="select-acct" class="select-account-accordion">Select Account(s)</h3>
<span id="account-selected" class="selected-account">0 of 8 account selected</span>
</div>
I am working on a simple html/css web page.
What I am trying to do is having an image and a div. Both will be inline display and in div I want to put a link. But when I put a long link title it is not what I expect it to be.
My code is this-
code
<div class="heading"> featured posts
</div>
<div class="img_src">
<img style="height:120px;" src="/uploads/1.jpg"></img>
</div>
<div class="link_src">
<a class="inside_link" href="#">Link will go here but if there is a long title then it may create some problems..</a>
</div>
</div>
CSS-
.img_src{
display: inline-block;
margin-top: 3px;
margin-left:-2%;
}
.link_src{
display: inline-block;
background-color: white;
height: 120px;
line-height: 120px;
width: 61%;
margin-top: 3px;
text-transform: uppercase;
}
.inside_link{
margin-left: 2%;
margin-right: 2%;
font-size: 15px;
}
.heading{
display: block;
background-color: #000;
color: #fff;
font-family: "Roboto Condensed","HelveticaNeue-CondensedBold","Helvetica Neue",Helvetica,Arial,Geneva,sans-serif;
font-size: 20px;
margin-top:5px;
font-color:white;
margin-left:-2%;
margin-right:-2%;
text-align: center;
line-height: 40px;
height: 40px;
font-style: oblique;
text-transform: uppercase;
}
I searched on google and StackOverflow but I did not get anything useful.
I want it to look like this(DIV wraps full)-
Any suggestion?
You csn use diplay:table-cell instead of inline-block but also I made edit in html by adding div.post that contain the image and title, and remove the inline-style that gave height to the image
<div class="post">
<div class="img_src">
<img src="http://i.dailymail.co.uk/i/pix/2016/03/22/13/32738A6E00000578-3504412-image-a-6_1458654517341.jpg">
</div>
<div class="link_src">
<a class="inside_link" href="#">Link will go here but if there is a long title then it may create some problems..</a>
</div>
</div>
and in the css I give width:20%; to .img_src and width:80%; to .link_src (you can change the widths as you like) and remove height and line height from them and the diplay:table-cell will handle those height
.post{
font-size:0;
display:table;
width:100%;
}
.img_src{
display: table-cell;
vertical-align:top;
width:20%;
}
.img_src img{
width:100%;
}
.link_src{
display: table-cell;
background-color: white;
margin-top: 3px;
text-transform: uppercase;
vertical-align:middle;
width:80%;
}
.inside_link{
margin-left: 2%;
margin-right: 2%;
font-size: 15px;
}
.heading{
display: block;
background-color: #000;
color: #fff;
font-family: "Roboto Condensed","HelveticaNeue-CondensedBold","Helvetica Neue",Helvetica,Arial,Geneva,sans-serif;
font-size: 20px;
margin-top:5px;
font-color:white;
margin-left:-2%;
margin-right:-2%;
text-align: center;
line-height: 40px;
height: 40px;
font-style: oblique;
text-transform: uppercase;
}
https://jsfiddle.net/IA7medd/gg7ygdLs/17/
You can achieve that by changing the inline-block display to table-cell and then apply the vertical-align:middle; property on the text container.
That way, the text will be perfectly vertically centered if there are one, two, three lines of content.
.parent{
display: table;
border: 5px solid #ccc;
width: 100%;
}
.img_src{
display: table-cell;
}
.link_src{
display: table-cell;
vertical-align: middle;
background-color: white;
width: 61%;
text-transform: uppercase;
}
See this fiddle
Ok you are using the wrong approach. Line height is causing you the problem. Your html should look like this
<img class="img_src" style="height:120px;" src="/uploads/1.jpg">
<div class="link_src">
<div class="inner_link_src">
<div class="inner_margin">
Link will go here but if there is a long title then it may create some problems..
</div>
</div>
</div>
and your css like this
.img_src{
float:left
}
.link_src{
float:left;
position:relative;
width: 61%;
text-transform: uppercase;
background-color: white;
vertical-align: top;
display:table;
height:120px;
}
.inner_link_src{
display:table-cell;
width:100%;
height:100%;
vertical-align:middle;
margin-left:10px;
}
.inner_margin{
margin-left:10px;
}
see the jsfiddle it is working great
https://jsfiddle.net/gg7ygdLs/27/
You just change your CSS and HTML by following and then you get the desired result.
CSS:
.img_src{
display: inline-block;
margin-top: 3px;
margin-left:-2%;
}
.link_src{
display: inline-block;
background-color: white;
height: 120px;
width: 100%;
margin: 10px 0 10px 3px;
-webkit-box-shadow: 7px 0px 0px 3px rgba(204,204,204,1);
-moz-box-shadow: 7px 0px 0px 3px rgba(204,204,204,1);
box-shadow: 7px 0px 0px 3px rgba(204,204,204,1);
}
.inside_link{
margin: 2%;
display: inline-block;
position:absolute;
padding: 8px;
}
.heading{
display: block;
background-color: #000;
color: #fff;
font-family: "Roboto Condensed","HelveticaNeue-CondensedBold","Helvetica Neue",Helvetica,Arial,Geneva,sans-serif;
font-size: 20px;
margin-top:5px;
font-color:white;
margin-left:-2%;
margin-right:-2%;
text-align: center;
line-height: 40px;
height: 40px;
font-style: oblique;
text-transform: uppercase;
}
HTML:
<div class="heading"> featured posts
</div>
<div class="link_src">
<img style="height:120px;" src="http://smashinghub.com/wp-content/uploads/2011/11/Text-Shadow-Box.jpg" />
<a class="inside_link" href="#">Link will go here but if there is a long title then it may create some problems..</a>
</div>
Demo
You can simplify your code a lot by using Flexbox.
You can use it for your header as well, to center the title.
.your-header {
display: flex;
align-items: center;
justify-content: center;
}
Then the image container. Use it's more semantic and it's a block element, perfect to wrap an image with a caption or a link in your case:
<figure class="your-figure">
<img class="your-image" src="http://pipsum.com/200x150.jpg"></img>
<a class="your-link" href="#">Link will go here but if there is a long title then it may create some problems..</a>
</figure>
and the CSS
.your-figure {
display: flex;
align-items: center;
padding: 4px;
border: 1px solid #ccc;
background-color: #fff;
}
.your-image {
margin-right: 10px;
}
Have a look here for the complete code ;)
Follow this if you don't know Flexbox, might seems daunting at first, but when it clicks in your head it will change your life :) Complete guide to Flexbox
I'm trying to create a navbar with some items on the left and some items on the right (Item 1 on the left, items 2 and 3 on the right). My JSFiddle has my current code.
What I have tried to fix this issue:
float: right
text-align:right
None of them seem to work. I'm sure there is a super simple solution, but I just can't think of it.
HTML:
<div class="navbar">
<!--Create the button home -->
<p class="innav">Num1</p>
<p class="HL">|</p>
<p class="rightIn">Num2</p>
<p class="HL">|</p>
<p class="rightIn">NUM 3</p>
<p class="HL">|</p>
</div>
CSS:
div.navbar{
width:100%;
height: 30px;
background-color: #03572c;
}
p{
display: inline;
}
p.innav{
color:white;
font-size: 24px;
width: 30px;
height: 30px;
margin-left: 10px;
margin-top: 10px;
}
p.rightIn{
color:white;
font-size: 24px;
width: 30px;
height: 30px;
margin-left: 10px;
margin-top: 10px;
}
.HL{
margin-left: 10px;
color:white;
font-size:24px;
}
JSfiddle
Any help would be greatly appreciated! :)
Add these style to your css.
p.rightIn,
p:nth-child(4),
p:nth-child(6)
{
float: right;
margin: 0px 5px;
width: auto;
}
Jsfiddle
I would recommend that you use a CSS grid system for this, since you are likely to need this functionality over a over on your sites.
Here are some grid systems that I have used in the past:
Pure CSS
http://purecss.io/grids/
Foundation
http://foundation.zurb.com/docs/components/grid.html
Bootstrap
http://getbootstrap.com/css/#grid
Semantic UI
http://semantic-ui.com/collections/grid.html
Or, if you feel like creating your own grid system, here is a good article about it:
http://www.sitepoint.com/understanding-css-grid-systems/
nav {
background: #000000;
width: 100%;
display: block;
padding: 8px 0;
font-family: arial;
font-size: 13px;
}
nav span {
display:block;
width:100%;
line-height: normal;
text-align:right;
}
nav a {
color: #ffffff;
padding: 0 10px;
text-decoration: none;
display:inline-block;
border-right:1px solid #ffffff;
}
nav a:first-child{
float:left;
}
nav a:last-child{
border:none;
}
<nav>
<span>
Link 1
Link 2
Link 3
</span>
</nav>
Demo
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;
}
http://jsfiddle.net/3V6MM/
Please tell me how can I write common style for class="property-title" to display the property name under the image.
Please guide me.
Images are placed like below
Have a look at this layout. Also note that ids should be unique. You are using image-thumb multiple times.
Live demo: http://jsfiddle.net/9C72X/
HTML
<div>
<div class="image-thumb">
<img src="http://www.javeacasas.com/images/javea-property.jpg">
<p class="property-title">Land for Sale</p>
</div>
<div class="image-thumb">
<img src="http://in.all.biz/img/in/service_catalog/15784.jpeg">
<p class="property-title">Sale at Mura, Puttur</p>
</div>
</div>
CSS
.image-thumb {
display: inline-block;
vertical-align: top; /* <-- update to solve multiline text */
width: 200px;
}
.image-thumb img {
width: 100%;
}
.property-title {
text-align: center;
font-size: 10px;
}
Personally I don't think you need to absolutely position the caption.
You might also consider using different mark-up.
<figure class="image-thumb">
<img class="imgthumg">
<figcaption class="property-title">
image title
</figcaption>
</figure>
try this, the float left is causing your image-thumb container to collapse.
.img-thumb {
position: relative;
padding-left: 5px;
word-spacing: 10px;
float: left;
}
.imgthumb {
width:230px;
height:161px;
background:#FFF;
border:1px solid #909090;
margin-left:10px;
margin-bottom: 30px;
}
.property-title {
bottom: 0;
font-family: 'Verdana';
font-size: 8pt;
margin-left: 10px;
margin-top: 10px;
width: 236px;
position: absolute;
}
Replace these css classes with the below one :
#image-thumb
{
padding-left: 5px;
word-spacing: 10px;
float:left;
}
.imgthumb
{
width:230px;
height:161px;
position:relative;
background:#FFF;
border:1px solid #909090;
margin-left:10px;
}
.property-title
{
font-family: 'Verdana';
font-size: 8pt;
margin-left: 10px;
margin-top: 0;
position: relative;
width: 236px;
}
http://jsfiddle.net/abhinavpratap/3V6MM/4/