I really dont know what to do.
I made a really simple guestbook, its ok and all, but when showing the comments
the text spills out from the div
I was trying with pre but didnt work
here is the css
.guestbook_content {
width: 100%;
height: 100%;
background: #FFE4E1;
padding: 5px;
font-size: 12px;
margin-bottom: 10px;
}
#box {
width: 628px;
height: 438px;
background: #fefefd ;
overflow-y: scroll;
overflow-x: hidden;
}
the html and php
<div id='box'>
<div id='box_title'></div>
<div id="box_text">
<?php
if(isset($_POST['mehet'])) {
$message= '';
$the_name= mysql_real_escape_string(strip_tags($_POST['nev']));
$comment = mysql_real_escape_string(strip_tags($_POST['comment']));
$date = date('Y.m.d H:i:s');
if(!empty($comment) && !empty($the_name)) {
//mysql_query("INSERT INTO vendeg (name, comment, date) VALUES ('$the_name', $comment', '$date')") or die(mysql_error());
mysql_query(" INSERT INTO guesstb(the_name, comment, date) VALUES ('$the_name', '$comment', '$date') ");
}else {
$message= '<b><font color="darkred">Pleasse fill out all inputs</b></font>';
}
}
?>
<?php echo $message; ?>
<form action='<?php echo the_permalink();?>' method='POST'>
<label for='nev' class='gbl'>Name:</label>
<input type='text' name='the_name' id='the_name' class='gbi'>
<label for='comm' class='gbl'>Comment:</label>
<textarea name='comment' id='comm' rows='5' cols='60' class='gbt'></textarea>
<input type='submit' class='submit' value='Beküld' name='mehet'>
</form>
<?php
$result = mysql_query("SELECT * FROM guesstbORDER BY date DESC");
while($row = mysql_fetch_array($result))
{
?><div class='guestbook_head'><span>sent by:</span> <b><?php echo $row['nev']; ?></b> <span> - date:</span> <?php echo $row['date']; ?> </div><?
?>
<div class='guestbook_content'><?echo $row['comment'];?></div>
<?
}
?>
could please someone could give me hint
.guestbook_content {
width: 100%; <-- drop this rule
height: 100%;
padding: 5px;
}
#box {
width: 628px;
}
You gave child div width: 100% + padding 5px, which makes = 100% of parent div :628px + 5px left padding + 5px right padding so child div is 638px wide. Just drop 100% width on child. All you need is padding.
Here is jsfiddle with your situation: http://jsfiddle.net/crg2U/2/
And here is with droped 100% width on child : http://jsfiddle.net/crg2U/3/
Related
I'm not sure where I'm going wrong with my CSS.. any help would be appreciated..
the CSS
#commentbox {
float: left;
margin-top: 10px;
background-color: #FFFFF0;
display: block;
width: 450px;
border: 1px solid #999999;
padding: 10px;
border-bottom-right-radius: 10px;
border-top-right-radius: 10px;
border-bottom-left-radius: 10px;
border-top-left-radius: 10px;
text-align: left;
}
#commentbox .commenter_name {
font-family: "Courier New", Courier, monospace;
font-size: 14px;
color: #660000;
float: left;
padding-left: 5px;
display: block;
}
#commentbox .comment_content {
display: block;
float: left;
clear: both;
white-space: pre-wrap;
}
This is my Form Textarea
<textarea name="vt_comment" cols="50" rows="5" wrap="hard" class="nontextarea" ></textarea>
This is the code that displays the Comment
<?php if ($totalRows_cmnts_disp>0) { // Show only if there are Comments
do { ?>
<div id="commentbox">
<!--Show Commenter Name -->
<div class="commenter_name">
<?php if ($row_cmnts_disp['member_nick']>"") {
echo $row_cmnts_disp['member_nick'] ;
} else {
echo $row_cmnts_disp['member_fname'] . ' ' . $row_list_solo['member_sname'] ;
} ?> commented
</div>
<!--Show Comment -->
<div class="comment_content">
<?php echo $row_cmnts_disp['vt_comment']; ?>
</div>
</div>
<?php } while ($row_cmnts_disp = mysql_fetch_assoc($cmnts_disp));
} // Show only if there are Comments loop ends
?>
This is how it gets stored in the DB
1st Line of the Comment
2nd Line of the Comment with just a Line break
Double Line Break
and this is how it is displayed on the site (with spaces in the front of the 1st line)
Swami Donanandha commented
hello
hello
hello
hello
as displayed online
whatever changes I try, I'm not able to remove the spaces before the 1st line of the comment, unless I remove the white-space:pre-wrap setting in the CSS...and if i do that the line breaks vanish displaying just one long sentence....
Swami Donanandha commented
1st Line of the Comment 2nd Line of the Comment with just a Line break Double Line Break
Have you tried removing the white-space: pre-wrap attribute and echo'ing a HTML break tag at the end of each comment?
<?php if ($totalRows_cmnts_disp>0) { // Show only if there are Comments
do { ?>
<div id="commentbox">
<!--Show Commenter Name -->
<div class="commenter_name"><?php if ($row_cmnts_disp['member_nick']>"") {
echo $row_cmnts_disp['member_nick'] ;
} else {
echo $row_cmnts_disp['member_fname'] . ' ' . $row_list_solo['member_sname'] ;
} ?>
commented
</div>
<!--Show Comment: Added Break Tag Below-->
<div class="comment_content">
<?php echo "<p class='comment'>" + $row_cmnts_disp['vt_comment'] + "</p><br>"; ?>
</div>
</div>
<?php } while ($row_cmnts_disp = mysql_fetch_assoc($cmnts_disp));
} // Show only if there are Comments loop ends
?>
The reason your comments concatenate into one long string after removing the white-space attribute is because of the float: left attribute in the .comment_content class. Updating the class to the following should fix the long string problem you have;
#commentbox .comment_content {
display: block;
}
I sorted it out... by adding the nl2br clause before the DB insert
$vt_comment = nl2br($_POST['vt_comment']);
and removing the white-space:pre-wrap from the CSS
Though I still don't have a clue why the extra spaces were getting added earlier :-)
I'm currently displaying a users profile picture in php and if they click on it, then it takes them through to their own profile. The image displays correctly and the link works, but the area of the link extends way beyond the picture and over a link nearby. How would I go about reducing the area of the anchor?
<?php } if ($searchuser == $username)
{ ?>
<a href="profile.php">
<?php } ?>
<div style="background-image: url('<?php echo $profilepic; ?> ')" class="user-pic"></div>
<?php if ($searchuser == $username)
{?>
</a>
div.user-pic {
margin: 0 auto;
width: 125px;
height: 125px;
border-radius: 50%;
background-repeat: no-repeat;
background-position: center center;
background-size: cover;
border: 0.09em solid white;
position: relative;
top: -60px;
padding: 0px;
z-index: -100;
}
Try with this:
php
<?php }
$show_user_link = false;
if ($searchuser == $username) {
$show_user_link = true;
}
?>
<div style="background-image: url('<?php echo $profilepic; ?>')" class="user-pic">
<?php if( $show_user_link ): ?>
<a class="user-link" href="profile.php">
</a>
<?php endif; ?>
</div>
css
div.user-pic {
position: relative;
}
a.user-link {
height: 125px;
width: 100%;
}
You put the anchor in within the div tag and then you could make div's position relative and anchor's width to 100%.
PS: You could try to use something like
<?php if(true): ?>
<strong> some html </strong>
<?php endif; ?>
when mixing php and html to make your code more readable.
--- EDIT
Ok, I understand, see if the new code is more helpfull now, the only thing I think that could go wrong is the height of the anchor in case it isnt fixed to 125px, say me if you have problems with it.
I have a form that wont stay aligned when I shrink the page. The div2 will move over to the left and intrude on div1 and the button positions become all jumbled. I have been reading up on css and thought the way to go was making a wrapper div then two child divs for my input types but it doesnt seem to work. I have tried all sorts of things I have found all to no avail. Ideally I would like the elements to all shrink proportionally and stay alaigned as the window shrinks. Absent that I would at least like the elements to just disappear off screen as it shrinks with scroll bars. Any help is musch appreciated.
HTML:
<form action="updated_tt.php" method="post">
<input type="hidden" name="ud_id" value="<?php echo $id; ?>" />
<div id="wrap">
<div id="div1">
Trouble Report/Request:<br/>
<textarea class="tt_fld5" name="ud_problem" maxlength="300" rows="3" wrap=HARD ><?php echo $problem; ?></textarea> <br/>
</div>
<div id="div2">
Action Taken: <br/>
<textarea class="tt_fld5" name="ud_act_tkn" maxlength="300" cols="40" rows="3" wrap=HARD ><?php echo $act_tkn; ?></textarea>
</div>
</div>
<br/>
<br/>
<?php
/* Here we create an array of the drop down list choices, then go thru the array one by one and check for the "selected" attribute.
If the value retrieved from MySQL equals the ddown_options array element then construct <option> line with the "selected" value, else construct
a normal <option> line. Note We have to Make this a form here.*/
$option_to_preselect = $tkt_status;
$ddown_options = array
(
'Open',
'Referred',
'Closed',
);
echo '<span class=tt_fld>Ticket Status: ' . '</span>' . '<br />';
$arrlength=count($ddown_options);
print '<select name="ud_ticket_status" id="input_select">';
for ($x=0;$x<$arrlength;$x++)
{
if ($ddown_options[$x] == $option_to_preselect)
{
print ' <option value="' . $ddown_options[$x] . '"' . ' selected="selected">' . $ddown_options[$x] . '</option>';
}
else {
print ' <option value="' . $ddown_options[$x] . '">' . $ddown_options[$x] . '</option>';
}
}
print '</select>';
echo '<br />';
echo '<br />';
/* For Assigned Tech...*/
echo '<span class=tt_fld>Assigned To: ' . '</span>' . '<br />';
$option_to_preselect = $assgnd_tech;
$ddown_options = array
(
'Unassigned',
'***',
'***',
'***',
'***',
);
$arrlength=count($ddown_options);
print '<select name="ud_assgnd_tech" id="input_select">';
for ($x=0;$x<$arrlength;$x++)
{
if ($ddown_options[$x] == $option_to_preselect)
{
print ' <option value="' . $ddown_options[$x] . '"' . ' selected="selected">' . $ddown_options[$x] . '</option>';
}
else {
print ' <option value="' . $ddown_options[$x] . '">' . $ddown_options[$x] . '</option>';
}
}
print '</select>';
?>
<br />
<center><button type="submit" class="btn btn-primary btn-lg" onclick="updated.php">Update Trouble Ticket</button></center>
<br />
<!-- Indicates a dangerous or potentially negative action -->
<center><button type="button" class="btn btn-danger" onclick="Del_Function()">Delete Trouble Ticket</button></center>
</form>
CSS:
#wrap {
overflow: hidden;
padding: 2px 0 0 0;
width: 94%;
margin: 25 auto;
}
#div1 {
font-weight: bold;
font: x-large serif;
font-weight: bold;
float: left;
width: 47%;
margin-top: 10px;
}
#div2 {
font: large serif;
float: right;
width: 47%;
margin-top: 10px;
font-weight: bold;
font-size: x-large;
}
The float attribute is specifically used to allow content to flow around block content depending on page dimensions. Instead of floating your content divs, try relative positioning.
Here's the CSS that worked for me just for the record:
#wrap {
overflow: hidden;
padding: 2px 0 0 0;
width: 1200px;
min-height:150px;
margin: 25 auto;
}
#div1 {
font: large serif;
font-weight: bold;
position: relative;
left: 10px;
width: 300px;
font-size: x-large;
max-width:300px;
}
#div2 {
font: large serif;
font-weight: bold;
font-size: x-large;
position: relative;
left: 600px;
width: 300px;
bottom:155px;
}
I have a fixed div with dynamic loaded li elements. Now I want the div-content to scroll when there are more than 9 li elements and a scroll-bar:
This is what it looks like:
At the moment the fixed div goes on over the footer and the content can not be scrolled.
Here is the css for all divs:
#fixed-div {
position: fixed;
width: 30%;
margin-top:290px;
padding-top:20px;
padding-bottom: 20px; /* must be same height as the footer */
background-color: rgba(255, 255, 255, 0.60);
min-height: 100%;
}
#absolute-div {
padding: 15px;
background-color: rgba(255, 255, 255, 0.60);
margin-bottom: 10px;
position: relative;
height: 200px;
}
#footer {
position: relative;
margin-top: -33px; /* negative value of footer height */
height: 20px;
line-height: 33px;
border-bottom:20px solid #fff;
text-align: left;
background-color:#fff;
padding-left:10px;
}
#map_canvas { /* background */
clear:left;
float: left;
width: 100%;
min-height: 100%;
z-index:-1001;
/* height: 530px;*/
-webkit-box-shadow: 0px 0px 10px #888;
-moz-box-shadow: 0px 0px 10px #888;
}
And here's the HTML:
<body>
<div id="searchbox">
<div id="absolute-div" class="clear-block">
<form method="post" action="./index.php" accept-charset="UTF-8" method="post" id="clinic-finder-form" class="clear-block" class="clear-block">
<label for="edit-gmap-address">Standort angeben und Vorteile in der Umgebung finden: </label>
<input type="text" maxlength="128" name="address" id="address" size="60" value="" class="form-text" autocomplete="off" />
<?php
// support unicode
mysql_query("SET NAMES utf8");
$cats = $db->get_rows("SELECT categories.* FROM categories WHERE categories.id!='' ORDER BY categories.cat_name ASC");
?>
<select name="products" class="form-select" id="edit-products" ><option value="">Alle Kategorien</option>
<?php if(!empty($cats)): ?>
<?php foreach($cats as $k=>$v): ?>
<option value="<?php echo $v['id']; ?>"><?php echo $v['cat_name']; ?></option>
<?php endforeach; ?>
<?php endif; ?>
</select>
<input type="submit" name="op" id="edit-submit" value="Vorteile finden" class="btn btn-primary" />
<input type="hidden" name="form_build_id" id="form-0168068fce35cf80f346d6c1dbd7344e" value="form-0168068fce35cf80f346d6c1dbd7344e" />
<input type="hidden" name="form_id" id="edit-clinic-finder-form" value="clinic_finder_form" />
<input type="button" name="op" onclick="document.location.href='newstore.php'" id="edit-submit" value="Unternehmen vorschlagen" class="btn btn-primary" />
</form>
</div></div>
<div id="fixed-div">
<div id="clinic-finder" class="clear-block">
<div id="results">
<ol style="display: block; " id="list"></ol>
</div>
</div>
</div>
<div id="map_canvas"></div>
<div id="footer">© 2008-2013 Ihr Vorteilsclub - Impressum</div>
Thanks a lot! Marcel
Add this to your css:
#results {
height: 100%;
overflow-y: scroll; /* adds scrollbar */
}
You can do this with absolute positioning. You still need overflow-y: scroll. Absolutely position the top of the dynamic section to the total height of the fixed elements above it and the bottom to the total height of the fixed elements below it. May need to tweak slightly but that should do the trick of consuming all the intermediate space and scrolling the overflow.
I am trying to get the next/prev links at the bottom of my blog to show up with just images. I have the positioning and the links set up correctly with the images that I want to use as well. The problem is though that the links are only working on the text that I used from the original code. I have the image that I want to use set up as the background of the div. I can not figure out how to make the image a link and delete the text.
Link to blog:
http://www.conutant.org/test-box/
What is have inside my PHP:
<div id="bottomnavigation">
<?php if($single) { ?>
<div class="nextprev">
<span class="prev"><?php previous_post('‹‹‹ %', 'PREVIOUS TUTORIAL', 'no', 'no'); ?></span>
<div id="homeicon"></div>
<span class="next"><?php next_post('% ›››', 'NEXT TUTORIAL', 'no', 'no'); ?></span>
</div>
<?php } ?>
</div>
And the CSS
.nextprev {
height: 100px;
}
.nextprev .prev {
float: left;
height: 100px;
width:200px;
background: url(http://www.conutant.org/wp-content/uploads/2012/12/Prev.png);
background-repeat: no-repeat;
background-position: left top;
margin-left: 19px;
}
.nextprev .next {
float: right;
height: 100px;
width:186px;
background: url(http://www.conutant.org/wp-content/uploads/2012/12/next.png);
background-repeat: no-repeat;
background-position: left top;
}
try with :
<div id="bottomnavigation">
<?php if($single) { ?>
<div class="nextprev">
<span class="prev"><img src="http://www.conutant.org/wp-content/uploads/2012/12/Prev.png" alt="<?php previous_post('‹‹‹ %', 'PREVIOUS TUTORIAL', 'no', 'no'); ?>" /></span>
<div id="homeicon"></div>
<span class="next"><img src="http://www.conutant.org/wp-content/uploads/2012/12/next.png" alt="<?php next_post('% ›››', 'NEXT TUTORIAL', 'no', 'no'); ?>"</span>
</div>
<?php } ?>
</div>
You don't need background in your css anymore
Apply the background image to the anchors, not to the spans.
.prev a {
float: left;
background: url(http://www.conutant.org/wp-content/uploads/2012/12/Prev.png);
}
.next a {
float: right;
background: url(http://www.conutant.org/wp-content/uploads/2012/12/next.png);
}
You also need to set the anchors as block elements:
.prev a,
.next a {
display:block;
}
And finally use text-indent: -9999px in order to hide text.