<div style="width: 1000px;height: 200px;float: left;opacity:0.9;border-color:#cc3e19;border-style:solid;margin-bottom:30px">
<div style="width: 500px;height: 100px;float:left;">
<?php for ($i = 1;$i<=$Breview;$i++) {
print '<span class = "reviewSpan" >★</span>';
}
?>
</div>
</div>
<style>
.reviewSpan{
color: #FFFF00;
}
</style>
I need to add <h2> tag around <span> tag to make star icon bigger but it prints stars vertically , how can i avoid it and make them print horizontally
Try below code-css
<span style="font-size: 50px;">★</span>
Related
I am trying a really easy thing, hiding / showing an info div my mouse-hovering another element. My code structure is similar to:
<div class="divRow">
<div class="divColumn">
<div class="divInfo">Info</div><img src="" /></div>
<div class="divInfo">Info</div><img src="" /></div>
<div class="divInfo">Info</div><img src="" /></div>
</div>
</div>
Image is shown, and there should be a blank space in which I want divInfo to appear.
I am using the following jQuery code to show / hide:
$(function() {
$('.divInfo').hide();
$('.divColumn').hover( function() { $('.divInfo').toggle(); } );
});
Of course, this works, but shows / hides all 3 divs in the row at a time. I want to be able to show hide each one separately...
Is this possible using classes? Or do I have to use a different unique ID for each??
Functionality I want is shown here, but I don't know how to do that. :)
http://www.therice-co.com
Regards and thanks
Actually you want the divs to always be there but somehow "not visible" when you are not hovering them. This is as simple as:
.divInfo:not(:hover){
opacity: 0;
}
Fiddle
This is what are you trying to achieve
see http://jsfiddle.net/j0aoy47L/
Javascript
<script>
$(function() {
$('.divInfo').hover( function() {
$(this).find('.info').toggle();
} );
});
</script>
CSS
<style>
.info{
display: none;
text-align: left;
}
.divInfo{
background: #fcfcfc;
border:1px solid #e5e5e5;
width:360px;
height:200px;
position: relative;
margin-bottom: 10px;
text-align: center;
padding:10px;
}
.divInfo img{
position: absolute;
bottom: 9px;
left: 19px;
}
</style>
HTML
<div class="divRow">
<div class="divColumn">
<div class="divInfo">
<div class="info"><h4>Image Caption</h4> <p>Some image information</p></div>
<img src="http://placehold.it/350x100/addd" />
</div>
<div class="divInfo">
<div class="info"><h4>Image Caption</h4> <p>Some image information</p></div>
<img src="http://placehold.it/350x100/addd" />
</div>
<div class="divInfo">
<div class="info"><h4>Image Caption</h4> <p>Some image information</p></div>
<img src="http://placehold.it/350x100/addd" />
</div>
</div>
$('.divColumn').children('a').hover(function () { // bind it to exact image
$(this).prev('.divInfo').toggle(); // show previous div
});
will work
jQuery DEMO
but you definetely have too much closing </div>s
also you can do it with pure CSS if you wrap each info and image in separate div and use :hover on it
PURE CSS DEMO
I want to display 30 same div. So I am taking for loop with showing 30 div. Now I want div in only one line. If the div is out of screen then it will show horizontal scroll bar.
The code is:
<div id="sort-able" >
<?php for($j=0;$j<30;$j++){?>
<div class = "dragg-able" >Home - <?php echo $j;?></div>
<?php } ?>
</div>
<div id="sort-able" style="width: 100%; overflow-x: scroll; white-space:nowrap;" >
<?php for($j=0;$j<30;$j++){?>
<div class = "dragg-able" style="display:inline; ">Home - <?php echo $j;?></div>
<?php } ?>
</div>
Example: http://kelostrada.pl/test.php
Problem:
I am trying to align divs next to each other using float:left but I can't get it to work. Instead, they are aligning under each other.
PHP code:
while ($row = mysql_fetch_assoc($result))
{
$kriterium .= '<div style="float:left;">'.$i.'</div>';
$betyg .= '<div style="float:left;">'.$row['RID'].'</div>';
$mean += $row['RID'];
$i++;
}
$meanvalue = round ($mean / ($i-1), 2);
$kriterium .= '<div style="float:left;"><b>Medelvärde</b></div>';
$betyg .= '<div style="float:left;"><b>'.$meanvalue.'</b></div>';
$html .= '
<div class="table table-condensed table-bordered neutralize">
<div>
<b>Kriterium</b>'.$kriterium.'
</div>
<div>
<b>Betyg</b>'.$betyg.'
</div>
</div>';
Desired output:
Question:
What is wrong with the CSS code that needs to be modified so that divs are aligned like columns next to each other?
You need to set a width for each div. The width of the first div will be wider than the width of the other divs.
<!DOCTYPE html>
<html>
<head>
<title>Kexx</title>
<style type='text/css'>
div.table-bordered > div {
width:420px;
}
div.table-bordered > div > div.c {
width:94px;
}
div.table-bordered > div > div {
float:left;
width:24px;
}
div.table-bordered div {
border:1px solid #333;
}
</style>
</head>
<body>
<div class="table table-condensed table-bordered neutralize">
<div>
<div class='c'><b>Kriterium</b></div>
<div>1</div>
<div>2</div>
<div>3</div>
<div>4</div>
<br style='clear:both;'/>
</div>
<div>
<div class='c'> <b>Betyg</b></div>
<div>A</div>
<div>B</div>
<div>C</div>
<div>D</div>
<br style='clear:both;'/>
</div>
</div>
</body>
</html>
http://jsfiddle.net/Zv7Dp/
try giving position as relative , btw , if you have a separate style sheet , you can define a class and put all style under one class , any way I still prefer a html table than this , and you can find as many as css table styles by googling !
I have the code below to split my for each statement into two separate divs:
<?php
$previousLetter = false;
?>
<?php
$i=1; // have a counter variable
foreach($this->clubs as $clubs) : ?>
<?php
$firstLetter = substr($clubs->club_name, 0, 1);
if ($firstLetter != $previousLetter) {
if($i==1){
echo "<div class="left_class">"; // open left div
}
?>
<h3 id="club-link-header"><u><?php echo $firstLetter; ?></u></h3>
<?php } ?>
<a id="club-link" href="<?php echo $this->url(array('controller' => 'club-description', 'action' => 'index', 'club_id' => $clubs->id));?>"><br />
<?php echo $this->escape($clubs->club_name);?></a>
<?php $previousLetter = $firstLetter; ?>
<?php
if($i==25){
echo "</div>"; //close left div
echo "<div class="right_class">"; // open right div
}
if($i==50){
echo "</div>"; //close right div
}
$i++; // increment the counter variable for each loop
endforeach;
?>
The HTML:
<body>
<div id="top">
<a id="admin-link" href="/MN/public/index.php/admin/index/id/1"></a>
<div id="logged-in-as">
Hello! ric89. Logout </div>
</div>
<div id="header">
<div id="header-wrapper">
<div id="social">
<a id="fb" href="#"><img src="/MN/public/images/fb.png" /></a>
<a id="twitter" href="#"><img src="/MN/public/images/twitter.png" /></a>
</div>
<div id="nav">
<div id="nav-left">
Home
</div>
<div id="nav-middle">
<a id="clubs-link" href="/MN/public/index.php/clubs/index/id/1">Clubs</a>
</div>
<div id="nav-right">
<a id="admin-link" href="/MN/public/index.php/admin/index/id/1">Admin</a>
</div>
</div>
<div id="logo">
</div>
</div>
</div>
<div id="content">
<h1>Clubs</h1>
//database content is echo'd here, 50 items like this:
<h3 id="club-link-header"><u>5</u></h3>
<a id="club-link" href="/MN/public/index.php/club-description/index/id/1/club_id/1"><br />
5th Avenue</a>
</div>
<div id="footer">
<p id="footer-text">created & designed by Richard Knight-Gregson</p>
</div>
</body>
The CSS:
/*Content styles */
.clubs-left {
width: 450px;
}
.clubs-right {
float: right;
margin-left: 450px;
position: absolute;
width: 450px;
}
.right_class {
float: right;
width: 450px;
}
.left_class {
position: absolute;
width: 450px;
}
.clear {
clear: both;
}
Here is an image of the problem -> http://imageshack.us/photo/my-images/84/screenshot20120426at211.png/ The footer should be 100% width.
The issue is I can't float the div right without breaking the layout as the right div needs to be on top of the left in the code but doing so will break the PHP.
Any suggestions?
Thanks
Since the problem that you are describing seams to be purely cosmetic, I believe that you need to clear the float to allow the document to continue its normal rendering:
After your <div class="right_class">...</div>:
HTML
<div class="clear"></div>
CSS
.clear {clear: both;}
wouldn't something like this be more efficient?
Break up your list by alphabet to start...
var glossary=array();
var $half=(int)count($this=>clubs);
var $count=0;
foreach ($this->clubs as $clubs){
$glossary[substr($clubs->club_name, 0, 1)][] = $clubs;
}
# Start a definition list. (http://www.w3schools.com/tags/tag_dl.asp)
echo'<dl>';
foreach ($glossary as $letter => $clubs){
$count++;
$class=($count>=$half)?'float_left':'float_right';
# list all the clbs broken down by letter
echo"<dt class='$class'>$letter</dt>";
foreach ($clubs as $club)
{
echo"<dd class='$class'>
<a id='club-link' href='" . $this->url(array('controller' => 'club-description', 'action' => 'index', 'club_id' => $club->id)) . "'>
" . $this->escape($clubs->club_name) .
"</a>
</dd>";
}
}
echo '</dl>';
and the css:
dl{
width:100%;
}
.float_left{
width:49%;
float:left;
clear:left;
}
.float_right{
width:49%;
float:right;
clear:right;
}
this way after you hit the halfway point in clubs, the dt and dd elements stack on the right side, and the list will automatically balance, no matter how many clubs you have.
It turns out the footer was inside the content div and I hadn't closed the content div properly one more extra before the footer starts was all it needed! Sorry to waste your time..
I generate all my html on my page with ajax calls and never refresh my page. My setup is something like
HTML: <a id="user_click_here">test link</a>
JQUERY:
$("#user_click_here").live("click", function(event){
console.log("click on test link");
ajax_function("action=return_some_html");
});
The ajax function calls php, where I create the html. What I struggle with is to generate html with php. I try to use this:
PHP:
$html = <<<HTML
<div class="box">
<h2>
$text[0]
</h2>
<div class="block">
<div style="float:left; width: 35%; margin:5px; padding: 1em; background: white;">
HTML;
$html .= '<p>Username: <a id="username">' . $_SESSION['username'] . '</a></p>';
$html .= <<<HTML
<div style="float:left; width: 30%; margin:5px;">
<p>
Level:<br />
Weapon:<br />
Power:<br />
Bullets:<br />
</p>
</div>
<div style="float:right; width: 60%; margin:5px;">
<p>
HTML;
$html .= '<b id="level">empty</b><br/>';
$html .= <<<HTML <---ERROR HERE unexpected '<<'
Weapon blabla<br />
2 - 5<br />
3/6<br />
</p>
</div>
</div>
I tend to just try and fail until it works with this <<<WHATEVER (dont remember what it's called). Like now where I get an unexpected '<<' error for some reason.
Do I have to use this method:
$html = '<div class="box">
<h2>
' . $text[0] . '
</h2>
<div class="block">
<div style="float:left; width: 35%; margin:5px; padding: 1em; background: white;">';
?
What is the best way to save html in php and send it back to jquery.
I send the html like this now:
PHP:
$data = array("html" => $html);
return json_encode( $data );
Off course I want it compressed as much as possible, preferably without any stuff like this: \n\t\t\t\t to take up space.
EDIT:
Ok. I don't think everybody noticed the fact that this is an ajax call and I have to return a json element. I cannot do the common <?php php code ?> html code <?php more php ?> some html
It looks like your last HEREDOC (that's what the <<< syntax is called) is unclosed, missing it's
HTML;
And don't forget that the final HTML; cannot have any whitespace on the same line before or after it.
However, you're going about it all wrong. The great thing about the HEREDOC syntax is that you can embed all your variables into it without requiring any concatenation. Just create the whole thing in one HEREDOC and echo it out to jQuery. There's no need to make it JSON if you are just going to use it as HTML when received by the AJAX call.
All your code above belongs inside one $html = <<<HTML block. Enclose all your complex variables like $_SESSION['whatever'] in {} {$_SESSION['whatever']}.
$html = <<<HTML
<div class="box">
<h2>
{$text[0]}
</h2>
<div class="block">
<div style="float:left; width: 35%; margin:5px; padding: 1em; background: white;">
<p>Username: <a id="username"> {$_SESSION['username']}</a></p>
<div style="float:left; width: 30%; margin:5px;">
<p>
Level:<br />
Weapon:<br />
Power:<br />
Bullets:<br />
</p>
</div>
<div style="float:right; width: 60%; margin:5px;">
<p>
<b id="level">empty</b><br/>
<!--etc -->
<!--etc -->
HTML;
// Now just echo it back to the AJAX caller as HTML
echo $html;
exit();
Don't use HEREDOC. It's messy, and should only be used when you need to store long strings in a variable.
Try writing out the HTML page you expect to be returned as if it was a normal HTML page. Where you need PHP output (a variable, array value, etc.), begin a PHP tag, echo the value, and then end the PHP tag. This is much easier than trying to use heredoc.
<div class="box">
<h2><?php echo $text[0]; ?> </h2>
<div class="block">
<div style="float:left; width: 35%; margin:5px; padding: 1em; background: white;">
<p>Username: <a id="username"><?php echo $_SESSION['username']; ?></a></p>
<div style="float:left; width: 30%; margin:5px;">
<p>Level:<br />Weapon:<br />Power:<br />Bullets:<br /></p>
</div>
<div style="float:right; width: 60%; margin:5px;">
<p><strong id="level">empty</b><br />Weapon blabla<br />2 - 5<br />3/6<br /></p>
</div>
</div>
If you're worried about line breaks (you shouldn't be), you can add an output handler that removes them.
ob_start("clean_linebreaks");
function clean_linebreaks($input) {
return str_replace("\n", "", str_replace("\r", "", $input));
}
Also, may I suggest using tables instead of floated divs. The level, weapon, and power will be easier to line up with their values if you use a table.