I would like to change the size of this facebook style comment box. I don't have any experience or knowledge of CSS and I couldn't figure out which CSS block to modify. Thanks in advance. I have included the CSS file and the file that utilizes the CSS specs. Thanks again.
.emAddComment{
background-color: #ECEFF5;
border-bottom: 1px solid #E5EAF1;
clear: left;
float: none;
margin-bottom: 2px;
overflow: hidden;
padding: 5px 15px 4px 5px;
display: block;
font-size: 11px;
color: #333;
font-family: "lucida grande",tahoma,verdana,arial,sans-serif;
text-align: left;
}
input.emButton{
padding: 2px 4px 3px;
color: #FFF;
background-color: transparent;
border: medium none;
cursor: pointer;
display: block;
font-weight: bold;
font-size: 11px;
margin: 0;
overflow: visible;
width: auto;
}
span.emButton{
background-color: #5B74A8;
border-color: #29447E #29447E #1A356E;
border-width: 1px;
border-style: solid;
display: inline-block;
outline: medium none;
vertical-align: bottom;
}
.emAddComment textarea{
width: 50%;
height: 29px;
overflow: hidden;
margin: 0 10px 5px 0;
min-height: 29px;
border: 1px solid #BDC7D8;
font-family: "lucida grande",tahoma,verdana,arial,sans-serif;
font-size: 11px;
padding: 3px;
}
.emAddComment .addEmMail, .emAddComment .addEmName{
margin: 0 10px 5px 0;
border: 1px solid #BDC7D8;
font-family: "lucida grande",tahoma,verdana,arial,sans-serif;
font-size: 11px;
padding: 3px;
width: 200px;
}
.emAddComment label{
width: 75px;
text-align: right;
}
.emComment{
background-color: #ECEFF5;
border-bottom: 1px solid #E5EAF1;
clear: left;
float: none;
margin-bottom: 2px;
overflow: hidden;
padding: 5px 0 4px 5px;
display: block;
color: #333;
}
.emInfoMessage{
background-color: #FFEFF5;
border-bottom: 1px solid #E5EAF1;
clear: left;
float: none;
margin-bottom: 2px;
overflow: hidden;
padding: 5px 0 4px 5px;
display: block;
color: #333;
text-align: center;
font-weight: bold;
}
.emComment .emCommentImage{
float: left;
}
.emComment .emCommentText{
padding-right: 7px;
margin-left: 40px;
}
.emComment .emCommentInto{
color: #777;
padding: 7px 7px 1px;
text-align: right;
}
.emShowAllComments, .emHideAllComments{
border-bottom: 1px solid #E5EAF1;
clear: left;
float: none;
margin-bottom: 2px;
overflow: hidden;
padding: 5px 0 4px 5px;
display: block;
color: #333;
background: #ECEFF5 url('images/comments.png') no-repeat 5px 4px;
padding-left: 26px;
}
#emContent, .emContent{
font-family: "lucida grande",tahoma,verdana,arial,sans-serif;
font-size: 11px;
}
#emContent a, .emContent a{
text-decoration: none;
color: #3B5998;
}
#emContent a:hover, .emContent a:hover{
text-decoration: underline;
}
.emSenderName{
font-weight: bold;
}
.emAddComment .addEmPot{
display: none;
}
.emCommentLike{
margin-top: 5px;
color: #777;
}
<?php
require_once('commentanything/config.inc.php');
require_once('commentanything/funcs.inc.php');
## check if there is a moderation action ###
#
$actionType = null;
$actionComleted = false;
if($_GET['emAct'] and $_GET['emCommentKey'] and $_GET['emCommentID'] and $_GET['emCommentOID']){
//check if the comment exists and I have access
if($comment = $db->query("SELECT * FROM em_comments WHERE id = ".(int)$_GET['emCommentID']." AND object_id = ".(int)$_GET['emCommentOID']." AND access_key = ".$db->quote($_GET['emCommentKey']))->fetch()){
switch($_GET['emAct']){
case 'delete': {
$actionCompleted = true;
$actionType = 'delete';
$db->query("DELETE FROM em_comments WHERE id = ".(int)$_GET['emCommentID']." AND object_id = ".(int)$_GET['emCommentOID']." AND access_key = ".$db->quote($_GET['emCommentKey']));
break;
}
case 'allow': {
$actionCompleted = true;
$actionType = 'allow';
$db->query("UPDATE em_comments SET visible = '1' WHERE id = ".(int)$_GET['emCommentID']." AND object_id = ".(int)$_GET['emCommentOID']." AND access_key = ".$db->quote($_GET['emCommentKey']));
break;
}
}
}
}
#
## end check ###############################
//get comments from database
$myip = ip2long($_SERVER['REMOTE_ADDR']);
$comments = $db->query("SELECT DISTINCT
em_comments.*,
em_likes.vote
FROM em_comments
LEFT JOIN em_likes ON em_comments.id = em_likes.comment_id AND em_likes.sender_ip = ".$myip."
WHERE
object_id = ".$db->quote($object_id)." AND
visible = '1'
ORDER BY id")->fetchAll();
// -- form output ------------------------------------------------
$total = count($comments);
$counter = 1;
$html = '<div id="emContent_'.$object_id.'" class="emContent">';
if($actionCompleted){
$html .= '<div class="emInfoMessage">';
$html .= $lang['cid'].' '.(int)$_GET['emCommentID'].' '.$lang['wassuc'].' '.($actionType=='delete'?$lang['deleted']:$lang['moderated']).'!';
$html .= '</div>';
}
if($total > $CCOUNT){
$html .= '<div class="emShowAllComments" id="emShowAllComments_'.$object_id.'">
'.$lang['view'].' <span id="total_em_comments_'.$object_id.'">'.$total.'</span> '.$lang['view2'].' <noscript><em>This page needs JavaScript to display all comments</em></noscript>
</div>
<div class="emHideAllComments" id="emHideAllComments_'.$object_id.'" style="display: none;">
'.$lang['hide'].' <span id="total_em_comments_to_hide_'.$object_id.'">'.$total.'</span> '.$lang['view2'].'
</div>';
}
foreach($comments as $comment){
if($comment['sender_name']){
if($comment['sender_mail']){
$comment['sender_name'] = jsEncode($comment['sender_mail'], $comment['sender_name']);
}
$sender = '<span class="emSenderName">'.$comment['sender_name'].'</span>: ';
}else{
$sender = '';
}
if($comment['vote']){
$likeText = commentLikeText($comment['rating_cache']-1);
}else{
$likeText = ''.$lang['ilike'].'';
if($comment['rating_cache']){
$likeText .= ' — '.commentLikeText($comment['rating_cache'],false);
}
}
$html .= '<div class="emComment emComment_'.$object_id.' '.($counter < ($total - ($CCOUNT - 1))?'emHiddenComment emHiddenComment_'.$object_id:'').'" id="comment_'.$comment['id'].'" '.($counter < ($total - ($CCOUNT - 1))?'style="display:none"':'').'>
<div class="emCommentImage">
<img src="http://www.gravatar.com/avatar/'.gravatar($comment['sender_mail'], false).'" width="32" height="32" alt="Gravatar" />
</div>
<div class="emCommentText">
'.$sender.stripslashes($comment['comment_text']).'
</div>
<div class="emCommentInto">
'.strftime($DATEFORMAT,strtotime($comment['created'])).'
<div class="emCommentLike" style="'.($ALLOWLIKE?'':'display:none;').'">
<span id="iLikeThis_'.$comment['id'].'">
<em>'.$likeText.'</em>
</span>
</div>
</div>
</div>';
$counter++;
}
$html .= '</div>';
$html .= '<div id="emAddComment_'.$object_id.'" class="emAddComment">
<form method="post" action="commentanything/php/addComment.php" onsubmit="return false;">
<span '.($SHOWNAME?'':'style="display: none;"').' id="emNameSpan_'.$object_id.'" class="emNameSpan">
<label for="addEmName_'.$object_id.'">'.$lang['name'].':</label>
<input type="text" placeholder="'.$lang['enterName'].'" id="addEmName_'.$object_id.'" class="addEmName" name="sender_name" />
</span>
<span '.($SHOWMAIL?'':'style="display: none;"').' id="emMailSpan_'.$object_id.'">
<label for="addEmMail_'.$object_id.'">'.$lang['mail'].':</label>
<input type="text" placeholder="'.$lang['enterMail'].'" id="addEmMail_'.$object_id.'" class="addEmMail" name="sender_mail" />
</span>
<textarea placeholder="'.$lang['enterComment'].'" id="addEmComment_'.$object_id.'" class="addEmComment" name="comment"></textarea>
<input type="text" name="email" value="" id="addEmPot_'.$object_id.'" class="addEmPot" />
<input type="hidden" name="object_id" value="'.$object_id.'" />
<span class="emButton">
<input type="submit" class="emButton" id="emAddButton_'.$object_id.'" value="'.$lang['comment'].'" onclick="addEMComment(\''.$object_id.'\')" />
</span>
</form>
</div>';
//send reply to client
echo '<div id="'.$object_id.'" class="emComments" object="'.$object_id.'" class="ignorejsloader">'.$html.'</div>';
Trial/error is a way of learning. Try updating the width on the code below for instance:
.emAddComment textarea{
width: 50%;
height: 29px;
overflow: hidden;
margin: 0 10px 5px 0;
min-height: 29px;
border: 1px solid #BDC7D8;
font-family: "lucida grande",tahoma,verdana,arial,sans-serif;
font-size: 11px;
padding: 3px;
}
Related
I have an HTML page with embedded CSS styling. It has a form with an input button that says "Submit Payment" using #fjButton and height of 54, which gets obeyed. I also have an that has an id #fjButton2 with a height of 14... both set to !important. The #fjButton2 doesn't get obeyed. Im's sure it's some stupid thing, but i just can't figure it out... the stays at 32px no matter what i do. See it at:
https://codepen.io/johnstonf/full/YzwGqNO
<!DOCTYPE html>
<html>
<head>
<title>Test-Store</title>
<link href="https://fonts.googleapis.com/css?family=Fjalla+One|Inter&display=swap" rel="stylesheet">
<!-- Landing page styling -->
<style type="text/css">
body{
background-color: #f2f4f9;
}
h3, h5{
font-family: 'Fjalla One', sans-serif;
font-weight: 100;
}
h3{
font-size: 36px;
}
h5{
font-size: 24px;
}
p, label{
font-family: 'Inter', sans-serif;
}
hr{
color:#fff;
background-color: #fff;
border-top:1px solid #fff;
margin-top:10px;
margin-bottom: 10px;
}
#container{
width:1200px;
margin:0 auto;
padding-top: 3%;
}
.column-6{
text-align: center;
width: 50%;
float:left;
}
#left-wrapper{
background-color: #72cca7;
box-shadow: 0 1px 3px 0 #dce0e6;
border-radius: 14px;
border: 3px solid black;
margin-right: 14px;
margin-top: 14px;
padding: 13px;
}
#right-wrapper{
padding-top: 13px;
margin-top: 13px;
border-radius: 14px;
border: 3px solid black;
margin-right: 14px;
background-color: #72cca7;
box-shadow: 0 1px 3px 0 #dce0e6;
border-radius: 14px;
border: 3px solid black;
margin-right: 14px;
margin-top: 14px;
padding: 13px;
}
#profile-pic{
width:200px;
display:block;
margin: 0 auto;
border-radius: 50%;
float:left;
}
#left-wrapper-header{
min-width:50%;
float:left;
padding-left:20px;
}
#left-wrapper-header h3{
color:#fff;
}
#right-wrapper h3{
color: #10a195;
}
.Z9999{
margin-left: 1px;
width: 99%;
}
/* ------------------------ FORM FIELDS ------------------------ */
.form-field-12{
width: 100%;
margin-bottom: 6px;
padding-top: 3px;
}
.form-field-6{
width: 50%;
float:left;
margin-bottom: 1px;
}
select{
width: 100%;
height: 25px!important;
box-shadow: 0 1px 3px 0 #dce0e6;
padding: 1px 2px;
border-radius: 4px;
background-color: #fff;
border: 1px solid transparent;
font-size: 20px;
color: #44464a;
}
input{
box-shadow: 0 1px 3px 0 #dce0e6;
height:40px;
border-radius: 4px;
background-color: #fff;
border: 1px solid transparent;
color: #44464a;
width: 95%;
padding: 5px;
font-size: 16px;
}
input::placeholder {
color: #9fa1a6;
}
/* ------------------------ BUTTON STYLING ------------------------ */
#fjButton {
box-shadow: 0 1px 3px 0 #dce0e6;
font-family:'Fjalla One', sans-serif;;
border-radius: 4px;
background-color: #fff;
border: 1px solid transparent;
color: #44464a;
height: 54px !important;
width: 30%;
padding: 5px;
font-size: 16px;
text-decoration:none;
margin: 0px;
}
#fjButton2 {
box-shadow: 0 1px 3px 0 #dce0e6;
font-family:'Fjalla One', sans-serif;;
border-radius: 4px;
background-color: #fff;
border: 1px solid transparent;
color: #44464a;
height: 14px !important;
width: 30%;
padding: 5px;
font-size: 16px;
text-decoration:none;
margin: 0px;
}
.myButton:hover {
opacity: .6;
}
#media screen and (max-width:1200px){
#container{
width:80%;
}
.column-6{
width: 100%;
}
}
#media screen and (max-width:800px){
#container{
width:100%;
}
.Z9999{
margin-left: 20px;
width: 100px;
}
}
</style>
<!-- Success page styling -->
<style type="text/css">
h4{
font-family: 'Fjalla One', sans-serif;
font-weight: 100;
font-size: 24px;
}
#box{
max-width: 500px;
margin:0 auto;
margin-top: 100px;
padding:30px;
background-color: #fff;
text-align: center;
box-shadow: 0 1px 3px 0 #dce0e6;
border-radius: 4px;
border: 1px solid transparent;
}
.myButton {
background-color:#72cca7;
background-color:#26367e;
display:inline-block;
cursor:pointer;
color:#ffffff;
font-family:Verdana;
font-size:17px;
padding:10px;
width:30%;
border-radius: 0;
text-decoration:none;
text-align: center;
transition: .3s;
}
.myButton:hover {
opacity: .6;
}
#succes-icon{
width: 100px;
}
</style>
</head>
<body>
<style type="text/css">
.StripeElement {
box-sizing: border-box;
height: 40px;
padding: 10px 12px;
border: 1px solid transparent;
border-radius: 4px;
background-color: white;
box-shadow: 0 1px 3px 0 #e6ebf1;
-webkit-transition: box-shadow 150ms ease;
transition: box-shadow 150ms ease;
}
.StripeElement--focus {
box-shadow: 0 1px 3px 0 #cfd7df;
}
.StripeElement--invalid {
border-color: #fa755a;
}
.StripeElement--webkit-autofill {
background-color: #fefde5 !important;
}
</style>
<script src="https://js.stripe.com/v3/"></script>
<div id="container">
<div class="column-6">
<div id="left-wrapper">
<img id="profile-pic" src="{% static 'images/logo-20may29.png' %}">
<div id="left-wrapper-header">
<h3>Item Purchase</h3>
</div>
<div style="clear:left"></div>
<hr>
<!-- Add form here -->
<form action="{% url 'charge' %}" method="post" id="payment-form">
<div class="form-field-12">
<label for="amount"><b>Pick a product from this dropdown:</b></label>
<select required name="amount" id="amount">
<option selected value="1">$1 CAD ------> TEST</option>
<option value="1">$1 CAD -----> 1 item</option>
<option value="2">$2 CAD -----> 2 items</option>
<option value="3">$3 CAD ----> 3 items</option>
<option value="4">$4 CAD ----> 4 items</option>
<option value="5">$5 CAD ---> 5 items</option>
</select>
</div>
<div class="form-field-6">
<label for="email"><strong>* Enter your email address:</strong></label>
<input required type="email" name="email" placeholder="* email...">
</div>
<div class="form-field-6">
<label for="username"><strong>* Desired username / login name:</strong></label>
<input required type="text" name="username" placeholder="* username...">
</div>
<div class="form-field-6">
<label for="email"><strong>Enter your Dogs name:</strong></label>
<input type="text" name="dog" placeholder="Dogs name...">
</div>
<div class="form-field-6">
<label for="email"><strong>Enter your Favorite beer:</strong></label>
<input type="text" name="beer" placeholder="Favorite beer...">
</div>
<div class="form-field-6">
<label for="country"><strong>* Enter your Country:</strong></label>
<input required type="text" name="country" placeholder="* Country...">
</div>
<div class="form-field-6">
<label for="phone"><strong>* Enter your phone number:</strong></label>
<input type="tel" id="phone" name="phone" placeholder="* Phone..."
pattern="[0-9]{3}-[0-9]{3}-[0-9]{4}"
required>
<small>Format: 123-456-7890</small>
</div>
<div class="form-row">
<label for="card-element">
<strong>Credit or debit card</strong>
</label>
<div id="card-element">
<!-- A Stripe Element will be inserted here. -->
</div>
<!-- Used to display form errors. -->
<div id="card-errors" role="alert">
</div>
</div>
<div style="clear:left">
</div>
<hr>
<input id="fjButton" style="background-color:#10a195;height:12px" type="submit" value="Submit Payment" name="">
<hr>
<a href="https://opp.ca" target="_blank" id="fjButton2" style="background-color:#10a195; height:77px" >OPP Homepage</a>
<br><br><br><br>
</form>
</div>
</div>
<div class="column-6">
<div id="right-wrapper">
<img class="form-field-12" src="{% static 'images/Z9999.png' %}">
<h3> We appreciate you!</h3>
<hr>
</div>
</div>
</div>
<script>
// Create a Stripe client.
var stripe = Stripe('pk_live_blahblah');
// Create an instance of Elements.
var elements = stripe.elements();
// Custom styling can be passed to options when creating an Element.
// (Note that this demo uses a wider set of styles than the guide below.)
var style = {
base: {
color: '#32325d',
fontFamily: '"Helvetica Neue", Helvetica, sans-serif',
fontSmoothing: 'antialiased',
fontSize: '16px',
'::placeholder': {
color: '#aab7c4'
}
},
invalid: {
color: '#fa755a',
iconColor: '#fa755a'
}
};
// Create an instance of the card Element.
var card = elements.create('card', {style: style});
// Add an instance of the card Element into the `card-element` <div>.
card.mount('#card-element');
// Handle real-time validation errors from the card Element.
card.addEventListener('change', function(event) {
var displayError = document.getElementById('card-errors');
if (event.error) {
displayError.textContent = event.error.message;
} else {
displayError.textContent = '';
}
});
// Handle form submission.
var form = document.getElementById('payment-form');
form.addEventListener('submit', function(event) {
event.preventDefault();
stripe.createToken(card).then(function(result) {
if (result.error) {
// Inform the user if there was an error.
var errorElement = document.getElementById('card-errors');
errorElement.textContent = result.error.message;
} else {
// Send the token to your server.
stripeTokenHandler(result.token);
}
});
});
// Submit the form with the token ID.
function stripeTokenHandler(token) {
// Insert the token ID into the form so it gets submitted to the server
var form = document.getElementById('payment-form');
var hiddenInput = document.createElement('input');
hiddenInput.setAttribute('type', 'hidden');
hiddenInput.setAttribute('name', 'stripeToken');
hiddenInput.setAttribute('value', token.id);
form.appendChild(hiddenInput);
// Submit the form
form.submit();
}
</script>
</body>
</html>
I found this finally... CSS - Why am I not able to set height and width of <a href> elements? and as it states...
"As the others have said, by default is an inline element, and inline elements can't specify a width or height. You can change it to be a block element like this":
a {
display: block;
}
Though it will then display (unsurprisingly) as a block, sitting on its own, outside the flow of the surrounding text. A better solution is to use display: inline-block which might be a best-of-both-worlds solution depending on your situation.
a {
display: inline-block;
}
Height won't have any effect on that <a> tag as it has a display of inline, so you simply need to change its display to something like inline-block to make it obey the set height, like
#fjButton2 {
box-shadow: 0 1px 3px 0 #dce0e6;
font-family:'Fjalla One', sans-serif;;
border-radius: 4px;
background-color: #fff;
border: 1px solid transparent;
color: #44464a;
height: 14px !important;
width: 30%;
padding: 5px;
font-size: 16px;
text-decoration:none;
margin: 0px;
display:inline-block;
}
Hope it helps.
I'm trying to make a list with people that have been stored in a mysql database, however only the first database item is styled properly and the others are out of place. I'm fairly new with css and I probably made a mistake in the while loop or positioning.
https://i.imgur.com/cKJqT6s.png
Image ^^
The code that I'm using is as followed:
<div id="adminsummary">
<div id="admintitel">
<p id="admintext">Admin Overview</p>
</div>
<?php
while ($row = mysqli_fetch_array($result)) {
$steamid = $row["steamid"];
$xml = simplexml_load_file("http://steamcommunity.com/profiles/$steamid/?xml=1");
if (!empty($xml)) {
$username = $xml->steamID;
}
?>
<div id="admin">
<img id="adminimg" src="<?php echo $steamprofile['avatarmedium']; ?>">
<p id="adminname"><?php echo $username; ?></p>
<!-- <p id="adminname"> SteamID: <?php echo $row["steamid"]; ?></p> -->
<p id="adminname"> Rank: <?php if ($row["rank"] == 1) {echo "SuperAdmin";} else {echo "Admin";} ?></p>
<hr id="hr2">
</div>
</div>
The stylesheet:
#adminsummary {
background: white;
margin-top: 5%;
height: 75%;
width: 25%;
margin-right: 5%;
float:right;
border-radius: 25px;
box-shadow: 10px 10px 77px -6px rgba(0,0,0,0.59);
}
#admintitel{
background: #343a40;
border-top-left-radius: 25px;
border-top-right-radius: 25px;
}
#admintext{
color: white;
font-family: sans-serif;
font-weight: bold;
text-align: center;
padding: 25px;
}
#adminimg {
border-radius: 25px;
float: left;
margin-left: 25px;
}
#hr2 {
display: block;
margin-top: 25px;
margin-bottom: 0.5em;
margin-left: auto;
margin-right: auto;
border-style: inset;
border-width: 1px;
}
#adminname {
text-align: left;
font-weight: bold;
margin-left: 25%;
font-family: sans-serif;
}
Thanks for taking the time to help me
Try putting classes instead of id in your divs and p inside the while loop.
IDs are unique in CSS, that explain why the first row is styled, not the others.
If you modify the HTML and remove the IDs within the loop you can use a combination of classes with child/sibling selectors to assign styles in a cleaner way
<!-- these IDs are OK as they are unique ( presumably ) -->
<div id="adminsummary">
<div id="admintitel">
<p id="admintext">Admin Overview</p>
</div>
<?php
while ($row = mysqli_fetch_array($result)) {
$steamid = $row["steamid"];
$xml = simplexml_load_file("http://steamcommunity.com/profiles/$steamid/?xml=1");
if (!empty($xml)) {
$username = $xml->steamID;
}
?>
<!-- use classes &/or sibling selectors for cleaner html ~ no duplicate IDs though -->
<div class="admin">
<img src="<?php echo $steamprofile['avatarmedium']; ?>">
<p><?php echo $username; ?></p>
<p> Rank: <?php if ($row["rank"] == 1) {echo "SuperAdmin";} else {echo "Admin";} ?></p>
<hr />
</div>
<?php
}//close loop
?>
</div>
the slightly modified CSS using child selectors to assign styles within the .admin code block
#adminsummary {
background: white;
margin-top: 5%;
height: 75%;
width: 25%;
margin-right: 5%;
float:right;
border-radius: 25px;
box-shadow: 10px 10px 77px -6px rgba(0,0,0,0.59);
}
#admintitel{
background: #343a40;
border-top-left-radius: 25px;
border-top-right-radius: 25px;
}
#admintext{
color: white;
font-family: sans-serif;
font-weight: bold;
text-align: center;
padding: 25px;
}
#adminsummary .admin img {
border-radius: 25px;
float: left;
margin-left: 25px;
}
#adminsummary .admin hr {
display: block;
margin-top: 25px;
margin-bottom: 0.5em;
margin-left: auto;
margin-right: auto;
border-style: inset;
border-width: 1px;
}
#adminsummary .admin p {
text-align: left;
font-weight: bold;
margin-left: 25%;
font-family: sans-serif;
}
Closed. This question needs details or clarity. It is not currently accepting answers.
Want to improve this question? Add details and clarify the problem by editing this post.
Closed 4 years ago.
Improve this question
I want to have equal space between text and button, but I am getting unequal space. See the image that I have attached; the red "delete" buttons and the text before that have unequal spaces.
Is there any CSS property that I can use so that the text doesn't push the button to the right?
function todo() {
var ParentDiv = document.getElementById('mydiv');
var newPara = document.createElement('p');
var value = document.getElementById('input-box').value;
var newText = document.createTextNode(value);
var del = document.createElement('input');
randomId = Math.random();
// newPara.setAttribute("id",randomId);
newPara.setAttribute("class", "para");
del.setAttribute("type", "button");
del.setAttribute("value", "delete");
del.setAttribute("onclick", "delt(this)");
del.setAttribute("class", "delbtn");
newPara.appendChild(newText);
newPara.appendChild(del);
ParentDiv.appendChild(newPara);
}
// function delt(me) {
// var parentId = me.parentElement.getAttribute("id");
// //var x = me.parentElement.nodeName;
// //console.log(parentId);
// document.getElementById(parentId).remove();
// }
function delt(me) {
var parent = me.parentNode;
var grandParent = parent.parentNode;
grandParent.removeChild(parent);
//console.log(grandParent);
}
//delt();
body {
margin-left: 25rem;
margin-top: 5rem;
margin-right: auto;
}
h1 {
margin-left: 4rem;
margin-right: auto;
}
#input-box {
font-size: 1.5em;
width: 50%;
margin-top: 5px;
padding: 5px;
border: none;
border-bottom: 2px solid blue;
}
#mybtn {
background-color: rgb(21, 170, 240);
border: none;
color: white;
padding: 15px 32px;
text-align: center;
text-decoration: none;
display: inline-block;
font-size: 16px;
margin: 10px 0 0 75px;
cursor: pointer;
}
.delbtn {
background-color: rgb(238, 53, 28);
border: none;
color: white;
text-align: center;
text-decoration: none;
display: inline-block;
font-size: 15px;
margin-top: 5px;
margin-left: 10px;
cursor: pointer;
}
.para {
text-align: left;
padding: 0;
margin: 0;
}
<h1>TODO APP</h1>
<input type="text" name="" id="input-box" maxlength="25">
<br><button id="mybtn" onclick="todo();">Add Item</button>
<div id="mydiv"></div>
View on GitHub
You could use a <table> instead of a <div> and append the p in the left column and the button in the right, so the buttons are always above each other:
function todo() {
var ParentDiv = document.getElementById('mytable');
var newRow = document.createElement('tr');
var leftCell = document.createElement('td');
var rightCell = document.createElement('td');
var newPara = document.createElement('p');
var value = document.getElementById('input-box').value;
var newText = document.createTextNode(value);
var del = document.createElement('input');
randomId = Math.random();
// newPara.setAttribute("id",randomId);
newPara.setAttribute("class", "para");
del.setAttribute("type", "button");
del.setAttribute("value", "delete");
del.setAttribute("onclick", "delt(this)");
del.setAttribute("class", "delbtn");
newPara.appendChild(newText);
rightCell.appendChild(del);
leftCell.appendChild(newPara);
newRow.appendChild(leftCell);
newRow.appendChild(rightCell);
ParentDiv.appendChild(newRow);
}
// function delt(me) {
// var parentId = me.parentElement.getAttribute("id");
// //var x = me.parentElement.nodeName;
// //console.log(parentId);
// document.getElementById(parentId).remove();
// }
function delt(me) {
var parent = me.parentNode;
var grandParent = parent.parentNode;
grandParent.removeChild(parent);
//console.log(grandParent);
}
//delt();
body {
margin-left: 25rem;
margin-top: 5rem;
margin-right: auto;
}
h1 {
margin-left: 4rem;
margin-right: auto;
}
#input-box {
font-size: 1.5em;
width: 50%;
margin-top: 5px;
padding: 5px;
border: none;
border-bottom: 2px solid blue;
}
#mybtn {
background-color: rgb(21, 170, 240);
border: none;
color: white;
padding: 15px 32px;
text-align: center;
text-decoration: none;
display: inline-block;
font-size: 16px;
margin: 10px 0 0 75px;
cursor: pointer;
}
.delbtn {
background-color: rgb(238, 53, 28);
border: none;
color: white;
text-align: center;
text-decoration: none;
display: inline-block;
font-size: 15px;
margin-top: 5px;
margin-left: 10px;
cursor: pointer;
}
.para {
text-align: left;
padding: 0;
margin: 0;
}
<h1>TODO APP</h1>
<input type="text" name="" id="input-box" maxlength="25">
<br><button id="mybtn" onclick="todo();">Add Item</button>
<table id="mytable"></table>
One method is to align the text to the left and button to the right.
Below, I've used flexbox.
Each .para contains a <span> for the text and an <input> button.
Those two elements are positioned using the flexbox layout, with justify-content:space-between.
function todo() {
var ParentDiv = document.getElementById('mydiv');
var newPara = document.createElement('p');
var value = document.getElementById('input-box').value;
var newText = document.createElement('span');
newText.innerHTML = value;
var del = document.createElement('input');
randomId = Math.random();
newPara.setAttribute("class", "para");
del.setAttribute("type", "button");
del.setAttribute("value", "delete");
del.setAttribute("onclick", "delt(this)");
del.setAttribute("class", "delbtn");
newPara.appendChild(newText);
newPara.appendChild(del);
ParentDiv.appendChild(newPara);
}
function delt(me) {
var parent = me.parentNode;
var grandParent = parent.parentNode;
grandParent.removeChild(parent);
}
#container {
width: 50%;
text-align: center;
}
#input-box {
font-size: 1.5em;
margin-top: 5px;
padding: 5px;
border: none;
border-bottom: 2px solid blue;
width: 100%;
box-sizing: border-box;
}
#mybtn {
background-color: rgb(21, 170, 240);
border: none;
color: white;
padding: 15px 32px;
text-align: center;
text-decoration: none;
display: inline-block;
font-size: 16px;
margin: 10px 0;
cursor: pointer;
}
.delbtn {
background-color: rgb(238, 53, 28);
border: none;
color: white;
text-align: center;
text-decoration: none;
display: inline-block;
font-size: 15px;
margin-top: 5px;
margin-left: 10px;
cursor: pointer;
}
.para {
text-align: left;
padding: 0;
margin: 0;
}
.para {
display: flex;
justify-content: space-between;
}
<div id="container">
<h1>TODO APP</h1>
<input type="text" name="" id="input-box" maxlength="25">
<br><button id="mybtn" onclick="todo();">Add Item</button>
<div id="mydiv">
<p class="para">
<span>Tester</span>
<input type="button" value="delete" onclick="delt(this)" class="delbtn">
</p>
<p class="para">
<span>Another Test</span>
<input type="button" value="delete" onclick="delt(this)" class="delbtn">
</p>
<p class="para">
<span>Sample Text</span>
<input type="button" value="delete" onclick="delt(this)" class="delbtn">
</p>
<p class="para">
<span>Item Title</span>
<input type="button" value="delete" onclick="delt(this)" class="delbtn">
</p>
</div>
</div>
I have a problem with my input.
As you can see, my input is taking up too much space. It doesn't have margin or padding.
Here's my code (I am using Boilerplate v5.3.0).
How can I fix it so it just takes the space that it needs?
$(document).ready(function() {
$('.selectList').hide();
$('.selectorWrapper a').click(function() {
hideShow(this);
});
$('ul.selectList li').click(function() {
changeText(this);
validate();
});
$('#email').keydown(function() {
var correo = $('#email').val();
if (validateMail(correo)) {
$('#email').css('borderColor', '#87e466');
validate();
} else {
$('#email').css('borderColor', '#ca3535');
validate();
}
});
function validateMail(email) {
var re = /^(([^<>()\[\]\\.,;:\s#"]+(\.[^<>()\[\]\\.,;:\s#"]+)*)|(".+"))#((\[[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}])|(([a-zA-Z\-0-9]+\.)+[a-zA-Z]{2,}))$/;
console.log(re.test(email));
return re.test(email);
}
function validate() {
var select1 = $('#selection1').text();
var select2 = $('#selection2').text();
var select3 = $('#selection3').val();
var email = $('#email').val();
if (select1 != 'Marca' && select2 != 'Modelo' && select3 != 'Anio' && validateMail(email)) {
$('#submitBtn').css({
'backgroundColor': '#bbd550',
'boxShadow': '0px 3px 0px 0px #9fbc2d'
});
$('#submitBtn').removeClass('disableClick');
} else {
$('#submitBtn').css({
'backgroundColor': '#808080',
'boxShadow': '0px 3px 0px 0px #636161'
});
$('#submitBtn').addClass('disableClick');
}
}
function hideShow(element) {
var thisId = $(element).attr('id');
var isHidden = $('#' + thisId).next().css('display');
console.log(isHidden);
if (isHidden == 'none') {
$('#' + thisId).next().slideDown();
} else {
$('#' + thisId).next().slideUp();
}
}
function changeText(element) {
var text = $(element).text();
$(element).parent().prev().text(text);
$(element).parent().prev().append('<i class="fa fa-chevron-down"></i>');
$(element).parent().slideUp();
$(element).parent().prev().css('borderColor', '#87e466')
}
});
html {
margin: 0;
padding: 0;
box-sizing: border-box;
}
input {
outline: none;
}
*,
*:before,
*:after {
box-sizing: inherit;
}
body {
margin: 0;
padding: 0;
font-family: 'Open Sans', sans-serif;
}
.disableClick {
pointer-events: none;
}
label {
display: none;
}
h3,
h2 {
margin: 0 auto;
padding: 0;
font-family: 'Open Sans', sans-serif;
}
header.site-header {
background-color: #000000;
width: 100%;
}
header.site-header h3 {
text-align: center;
color: #ffffff;
padding: 15px 0;
font-weight: normal;
font-size: 30px;
}
header.site-header h3 span {
font-weight: bold;
}
div.banner {
border-bottom: 5px solid #36aadd;
}
div.banner h2 {
font-size: 2em;
text-align: center;
font-weight: bold;
color: #36aadd;
padding: 15px 10px 10px 10px;
}
div.banner p {
color: #888888;
text-align: center;
margin: 0;
font-size: 1.2em;
padding-bottom: 50px;
font-family: 'Open Sans', sans-serif;
}
div.form {
padding: 20px 10px;
margin: 0;
background-color: #eeeeee;
}
a.selectButton {
text-decoration: none;
padding: 10px;
color: #888888;
background-color: #ffffff;
border: 1px solid #d0d0d0;
display: block;
width: 100%;
margin: 0;
}
a.selectButton i {
color: #d0d0d0;
float: right;
padding-right: 10px;
}
ul.selectList {
list-style: none;
padding: 0;
margin: 0;
border: 1px solid #d0d0d0;
width: 100%;
position: absolute;
}
ul.selectList li {
width: 100%;
padding: 10px 0 10px 10px;
display: block;
background-color: #ffffff;
}
ul.selectList li a {
display: block;
text-decoration: none;
color: #888888;
}
ul.selectList li:hover {
background-color: #d0d0d0;
}
div.selectorWrapper input {
margin: 0;
padding: 10px;
width: 100%;
border: 1px solid #d0d0d0;
border-top: none;
text-align: center;
font-family: 'Open Sans', sans-serif;
}
div.selectorWrapper {
/*width:100%;*/
}
.selectorWrapper:nth-child(2),
.selectorWrapper:nth-child(3) {
width: 50%;
float: left;
}
div.selectorWrapper .button {
background-color: #808080;
color: #FFFFFF;
margin-top: 30px;
border-radius: 4px;
margin-bottom: 20px;
font-size: 30px;
box-shadow: 0px 3px 0px 0px #636161;
border: none;
font-family: 'Open Sans', sans-serif;
}
div.recuperar {
text-align: center;
padding: 20px;
}
div.recuperar a.recupera-link {
text-decoration: none;
color: #5faadb;
font-size: 18px;
font-family: 'Open Sans', sans-serif;
}
.contenedorA {
position: relative;
}
#media only screen and (min-width: 768px) {
label {
display: block;
width: 30%;
float: left;
padding: 10px 0 0 15px;
text-align: left;
font-size: 0.9em;
}
div.banner {
border: none;
}
div.form {
background: #ffffff;
}
.contenedorA {
padding: 100px 50px 0 50px;
}
.contenedor {
width: 96%;
margin: 0 auto!important;
box-shadow: 0px 0px 10px 3px #f9f9f9;
margin-top: 50px;
}
div.selectorWrapper {
width: 80%;
margin: 20px auto;
}
div.selectorWrapper input,
div.selectorWrapper a.selectButton {
width: 70%;
float: right;
margin: 0 auto;
}
.selectorWrapper:nth-child(2),
.selectorWrapper:nth-child(3) {
width: 80%;
float: none;
position: relative;
}
ul.selectList {
position: relative;
margin-left: 420px;
margin-top: 44px;
}
div.selectorWrapper input {
border: 1px solid #d0d0d0;
}
div.recuperar {
padding-left: 100px;
}
}
<link href="https://fonts.googleapis.com/css?family=Open+Sans" rel="stylesheet">
<link rel='stylesheet' href='css/main.css' type="text/css">
<!--<link rel='stylesheet' href='css/normalize.css' type="text/css">-->
</head>
<body>
<header class='site-header'>
<h3><span>compara</span>online</h3>
</header>
<div class=contenedorA>
<div class="contenedor">
<div class="banner">
<h2>Cotiza tu Seguro Automotriz</h2>
<p>Resultados instantaneos!</p>
</div>
<div class="form clearfix">
<form method="post" action="">
<div class="selectorWrapper clearfix">
<label>Marca : </label>
<a class="selectButton" id="selection1" href="#">Marca<i class="fa fa-chevron-down"></i></a>
<ul class="selectList">
<li>Hyundai</li>
<li>Toyota</li>
<li>Nissan</li>
</ul>
</div>
<div class="selectorWrapper clearfix">
<label>Modelo : </label>
<a class="selectButton" id="selection2" href="#">Modelo<i class="fa fa-chevron-down"></i></a>
<ul class="selectList">
<li>Sedan</li>
<li>SUV</li>
<li>Pick-up</li>
</ul>
</div>
<div class="selectorWrapper clearfix">
<label>Anio: </label>
<a class="selectButton" id="selection3" href="#">Anio<i class="fa fa-chevron-down"></i></a>
<ul class="selectList">
<li>2017</li>
<li>2016</li>
<li>2015</li>
</ul>
</div>
<div class="selectorWrapper clearfix">
<!--<label>Email : </label>-->
<input type='email' name='email' class="clearfix" id='email' placeholder='Email' required>
</div>
<div class="selectorWrapper clearfix">
<input type='submit' class="button disableClick" id='submitBtn' value="Cotizar">
</div>
</form>
<div class="recuperar">
<a class="recupera-link" href="#">Recuperar cotizacion</a>
</div>
</div>
</div>
</div>
<script src="https://code.jquery.com/jquery-3.2.1.min.js" type="text/javascript"></script>
<script src='js/main.js' type="text/javascript"></script>
When you float an element, you remove it from the normal flow of the document. As a result, other block elements don't respect their space.
Since both elements on the line (Modelo and Anio) are float: left, the next block element (Email) doesn't see them, and takes their space. So the Email div now lies hidden under the split elements.
However, the input element inside the Email div is not a block element. It's an inline element, by default. And inline elements respect the space of floated elements. (This is how text is able to wrap around floated images.)
So in your code, while the Email div shifts below the split element (on the z-axis), the input inside the Email div stays below the split element (on the y-axis).
When you highlight the Email element in dev tools, it illustrates this split across two rows.
One solution is to give the Email div display: inline-block and width: 100%.
div.selectorWrapper:nth-child(4) {
display: inline-block;
width: 100%;
}
Another solution is to add clear: both to the Email div. (Read more about clearing floats.)
div.selectorWrapper:nth-child(4) {
clear: both;
}
$(document).ready(function() {
$('.selectList').hide();
$('.selectorWrapper a').click(function() {
hideShow(this);
});
$('ul.selectList li').click(function() {
changeText(this);
validate();
});
$('#email').keydown(function() {
var correo = $('#email').val();
if (validateMail(correo)) {
$('#email').css('borderColor', '#87e466');
validate();
} else {
$('#email').css('borderColor', '#ca3535');
validate();
}
});
function validateMail(email) {
var re = /^(([^<>()\[\]\\.,;:\s#"]+(\.[^<>()\[\]\\.,;:\s#"]+)*)|(".+"))#((\[[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}])|(([a-zA-Z\-0-9]+\.)+[a-zA-Z]{2,}))$/;
console.log(re.test(email));
return re.test(email);
}
function validate() {
var select1 = $('#selection1').text();
var select2 = $('#selection2').text();
var select3 = $('#selection3').val();
var email = $('#email').val();
if (select1 != 'Marca' && select2 != 'Modelo' && select3 != 'Anio' && validateMail(email)) {
$('#submitBtn').css({
'backgroundColor': '#bbd550',
'boxShadow': '0px 3px 0px 0px #9fbc2d'
});
$('#submitBtn').removeClass('disableClick');
} else {
$('#submitBtn').css({
'backgroundColor': '#808080',
'boxShadow': '0px 3px 0px 0px #636161'
});
$('#submitBtn').addClass('disableClick');
}
}
function hideShow(element) {
var thisId = $(element).attr('id');
var isHidden = $('#' + thisId).next().css('display');
console.log(isHidden);
if (isHidden == 'none') {
$('#' + thisId).next().slideDown();
} else {
$('#' + thisId).next().slideUp();
}
}
function changeText(element) {
var text = $(element).text();
$(element).parent().prev().text(text);
$(element).parent().prev().append('<i class="fa fa-chevron-down"></i>');
$(element).parent().slideUp();
$(element).parent().prev().css('borderColor', '#87e466')
}
});
div.selectorWrapper:nth-child(4) {
clear: both;
}
html {
margin: 0;
padding: 0;
box-sizing: border-box;
}
input {
outline: none;
}
*,
*:before,
*:after {
box-sizing: inherit;
}
body {
margin: 0;
padding: 0;
font-family: 'Open Sans', sans-serif;
}
.disableClick {
pointer-events: none;
}
label {
display: none;
}
h3,
h2 {
margin: 0 auto;
padding: 0;
font-family: 'Open Sans', sans-serif;
}
header.site-header {
background-color: #000000;
width: 100%;
}
header.site-header h3 {
text-align: center;
color: #ffffff;
padding: 15px 0;
font-weight: normal;
font-size: 30px;
}
header.site-header h3 span {
font-weight: bold;
}
div.banner {
border-bottom: 5px solid #36aadd;
}
div.banner h2 {
font-size: 2em;
text-align: center;
font-weight: bold;
color: #36aadd;
padding: 15px 10px 10px 10px;
}
div.banner p {
color: #888888;
text-align: center;
margin: 0;
font-size: 1.2em;
padding-bottom: 50px;
font-family: 'Open Sans', sans-serif;
}
div.form {
padding: 20px 10px;
margin: 0;
background-color: #eeeeee;
}
a.selectButton {
text-decoration: none;
padding: 10px;
color: #888888;
background-color: #ffffff;
border: 1px solid #d0d0d0;
display: block;
width: 100%;
margin: 0;
}
a.selectButton i {
color: #d0d0d0;
float: right;
padding-right: 10px;
}
ul.selectList {
list-style: none;
padding: 0;
margin: 0;
border: 1px solid #d0d0d0;
width: 100%;
position: absolute;
}
ul.selectList li {
width: 100%;
padding: 10px 0 10px 10px;
display: block;
background-color: #ffffff;
}
ul.selectList li a {
display: block;
text-decoration: none;
color: #888888;
}
ul.selectList li:hover {
background-color: #d0d0d0;
}
div.selectorWrapper input {
margin: 0;
padding: 10px;
width: 100%;
border: 1px solid #d0d0d0;
border-top: none;
text-align: center;
font-family: 'Open Sans', sans-serif;
}
div.selectorWrapper {
/*width:100%;*/
}
.selectorWrapper:nth-child(2),
.selectorWrapper:nth-child(3) {
width: 50%;
float: left;
}
div.selectorWrapper .button {
background-color: #808080;
color: #FFFFFF;
margin-top: 30px;
border-radius: 4px;
margin-bottom: 20px;
font-size: 30px;
box-shadow: 0px 3px 0px 0px #636161;
border: none;
font-family: 'Open Sans', sans-serif;
}
div.recuperar {
text-align: center;
padding: 20px;
}
div.recuperar a.recupera-link {
text-decoration: none;
color: #5faadb;
font-size: 18px;
font-family: 'Open Sans', sans-serif;
}
.contenedorA {
position: relative;
}
#media only screen and (min-width: 768px) {
label {
display: block;
width: 30%;
float: left;
padding: 10px 0 0 15px;
text-align: left;
font-size: 0.9em;
}
div.banner {
border: none;
}
div.form {
background: #ffffff;
}
.contenedorA {
padding: 100px 50px 0 50px;
}
.contenedor {
width: 96%;
margin: 0 auto!important;
box-shadow: 0px 0px 10px 3px #f9f9f9;
margin-top: 50px;
}
div.selectorWrapper {
width: 80%;
margin: 20px auto;
}
div.selectorWrapper input,
div.selectorWrapper a.selectButton {
width: 70%;
float: right;
margin: 0 auto;
}
.selectorWrapper:nth-child(2),
.selectorWrapper:nth-child(3) {
width: 80%;
float: none;
position: relative;
}
ul.selectList {
position: relative;
margin-left: 420px;
margin-top: 44px;
}
div.selectorWrapper input {
border: 1px solid #d0d0d0;
}
div.recuperar {
padding-left: 100px;
}
}
<link href="https://fonts.googleapis.com/css?family=Open+Sans" rel="stylesheet">
<link rel='stylesheet' href='css/main.css' type="text/css">
<!--<link rel='stylesheet' href='css/normalize.css' type="text/css">-->
</head>
<body>
<header class='site-header'>
<h3><span>compara</span>online</h3>
</header>
<div class=contenedorA>
<div class="contenedor">
<div class="banner">
<h2>Cotiza tu Seguro Automotriz</h2>
<p>Resultados instantaneos!</p>
</div>
<div class="form clearfix">
<form method="post" action="">
<div class="selectorWrapper clearfix">
<label>Marca : </label>
<a class="selectButton" id="selection1" href="#">Marca<i class="fa fa-chevron-down"></i></a>
<ul class="selectList">
<li>Hyundai</li>
<li>Toyota</li>
<li>Nissan</li>
</ul>
</div>
<div class="selectorWrapper clearfix">
<label>Modelo : </label>
<a class="selectButton" id="selection2" href="#">Modelo<i class="fa fa-chevron-down"></i></a>
<ul class="selectList">
<li>Sedan</li>
<li>SUV</li>
<li>Pick-up</li>
</ul>
</div>
<div class="selectorWrapper clearfix">
<label>Anio: </label>
<a class="selectButton" id="selection3" href="#">Anio<i class="fa fa-chevron-down"></i></a>
<ul class="selectList">
<li>2017</li>
<li>2016</li>
<li>2015</li>
</ul>
</div>
<div class="selectorWrapper clearfix">
<!--<label>Email : </label>-->
<input type='email' name='email' class="clearfix" id='email' placeholder='Email' required>
</div>
<div class="selectorWrapper clearfix">
<input type='submit' class="button disableClick" id='submitBtn' value="Cotizar">
</div>
</form>
<div class="recuperar">
<a class="recupera-link" href="#">Recuperar cotizacion</a>
</div>
</div>
</div>
</div>
<script src="https://code.jquery.com/jquery-3.2.1.min.js" type="text/javascript"></script>
<script src='js/main.js' type="text/javascript"></script>
In your question you are showing the properties of div, check properties of a tag inside div. The a tag is having padding:10px;.
This is happening because a.selectButton has padding of 10px. You can remove it completely or you can only remove the left padding to fix the problem.
a.selectButton {
padding-left: 0;
}
Insert the above code in your style tag to fix the problem.
Currently I am developing a Facebook like Messenger. Right now I am working under a chat-area, this thing should be fixed. But if I give position:fixed suddenly div disappear. I don't know what to do.
Here is my HTML/PHP code.
<?php
// Turn off all error reporting
//shop not login users from entering
if(isset($_SESSION['id'])){
$user_id = $_SESSION['id'];
}else{
}
require_once("./inc/connect.inc.php");
?>
<header>
<link rel="stylesheet" href="home - Copy.css" />
<nav>
<h3><a class="h3" href="#">Cp</a></h3>
<div>
<?php
//Start your session
session_start();
//Read your session (if it is set)
if (isset($_SESSION['user_login']))
echo $_SESSION['user_login'];
?>
</div>
<div><span>Logout</span></div>
<div><span>Settings </span></div>
</nav>
<body>
<div class="shead">
<div class="a1"> <li >Frequent Member</li>
<ul>
<?php
//show all the users expect me
$user_id = $_SESSION['id'];
$q = mysql_query("SELECT * FROM `users` WHERE id!='$user_id'");
//display all the results
while($row = mysql_fetch_assoc($q)){
echo "<a href='home.php?id={$row['id']}'><p>{$row['username']}</p></a>";
}
?>
</ul>
</div>
<div class="a2"> <li >Site's Popular in Your College</li></div>
</div>
</header>
<div class="rss">
<?php
//include('rssclass.php');
//sinclude('rss.php');
?>
<div class="message-right">
<!-- display message -->
<div class="display-message">
<?php
//check $_GET['id'] is set
if(isset($_GET['id'])){
$user_two = trim(mysql_real_escape_string( $_GET['id']));
//check $user_two is valid
$q = mysql_query( "SELECT `id` FROM `users` WHERE id='$user_two' AND id!='$user_id'");
//valid $user_two
if(mysql_num_rows($q) == 1){
//check $user_id and $user_two has conversation or not if no start one
$conver = mysql_query( "SELECT * FROM conversation WHERE (user_one='$user_id' AND user_two='$user_two') OR (user_one='$user_two' AND user_two='$user_id')");
//they have a conversation
if(mysql_num_rows($conver) == 1){
//fetch the converstaion id
$fetch = mysql_fetch_assoc($conver);
$conversation_id = $fetch['id'];
}else{ //they do not have a conversation
//start a new converstaion and fetch its id
$q = mysql_query( "INSERT INTO `conversation` VALUES ('','$user_id',$user_two)");
$conversation_id = mysql_insert_id($con);
}
}else{
die("Invalid $_GET ID.");
}
}else {
die("Click On the Person to start Chating.");
}
?>
</div>
<div class="send-message">
<!-- store conversation_id, user_from, user_to so that we can send send this values to post_message_ajax.php -->
<input type="hidden" id="conversation_id" value="<?php echo base64_encode($conversation_id); ?>">
<input type="hidden" id="user_form" value="<?php echo base64_encode($user_id); ?>">
<input type="hidden" id="user_to" value="<?php echo base64_encode($user_two); ?>">
<div class="textbox">
<input class="t_box" type="text" id="message" placeholder="Enter Your Message"/>
<button class="t_btn" id="reply">Reply</button>
<span id="error"></span>
</div>
</div>
</div>
<!--
<div class="textbox">
<form action="#" method="post">
<input type="text" name="msg_body" class="t_box" id="t_box" >
<input type="submit" class="t_btn" id="t_btn" name="submit" value="Send">
</form>
</div>-->
<script type="text/javascript" src="js/jquery.min.js"></script>
<script type="text/javascript" src="js/script.js"></script>
</body>
Here is my css and .message-right is the element where problem occurs.
#import url(http://fonts.googleapis.com/css?family=Roboto:400,100,100italic,300,300italic,400italic,500,500italic,700,700italic,900,900italic);
* {
margin: 0;
padding: 0;
box-sizing: border-box;
}
body {
font-family: 'Roboto', Arial, sans-serif;
background-color: #222;
overflow-x: hidden;
text-align: center;
}
header {
position: fixed;
width: 100%;
height: 50px;
background-color: #FFD700;
box-shadow: 0 3px 6px rgba(0, 0, 0, 0.16), 0 3px 6px rgba(0, 0, 0, 0.23);
}
header > nav > div {
float: right;
width: 10.6666%;
height: 100%;
position: relative;
}
header > nav > div > a {
text-align: center;
width: 100%;
height: 100%;
display: block;
line-height: 50px;
color: #222;
transition: background-color 0.2s ease;
text-transform: uppercase;
}
header > nav > div:hover > a {
background-color: rgba(0, 0, 0, 0.1);
cursor: pointer;
}
a{
text-decoration: none;
color: #000;
}
a:hover{
text-decoration: none;
background-color: #FFD700;
font-weight: bolder;
}
h3{
float: left;
height: 100%;
text-align: bottom;
padding-top: 10px;
padding-left: 10px;
}
.h3{
color: #222;
font-size:25px;
}
.nav{
position: fixed;
}
.title-head {
font-size:18px;
font-weight:bold;
text-align:left;
background-color:#F5F6F7;
color:#000;
float: left;
width: 455.33px;
}
.feeds-links {
text-align:left;
width: 455.33;
font-size: 20px;
padding:5px;
border:1px solid #dedede;
padding-top:inherit;
color: #000;
background-color: #FFFFFF;
}
.rss{
float: right;
padding-top: 100px;
}
.h2{
color: #000;
background: #ffd700;
height: 45px;
width: 455.33px;
padding-top: 10px;
box-shadow: 0 3px 6px rgba(0, 0, 0, 0.16), 0 3px 6px rgba(0, 0, 0, 0.23);
}
.textarea{
float: left;
padding-top:553px;
width: 455.3px;
position: fixed;
}
.t_box{
float: left;
border-radius: 5px;
border: 1px solid #FFD700;
background-color: #fff;
padding: 5px 5px;
font-size: 1em;
width: 78%;
outline: none;
}
.textbox{
background-color: #FFD700;
border: 1px solid #FFD700;
margin-top: 565px;
padding: 10px;
height: 50px;
width:455.5px;
float: left;
}
.t_btn{
text-decoration: none;
color:#222;
font-weight: bold;
background-color: transparent;
border: none;
font-size: 1em;
cursor: pointer;
height: 33px;
width: 70px;
outline: none;
}
.shead{
height: 50px;
width: 910px;
float: right;
margin-top: 0px;
background: #FFD700;
box-shadow: 0px 3px 6px rgba(0, 0, 0, 0.16), 0 3px 6px rgba(0, 0, 0, 0.23);
position: sticky;
border-top: #000;
}
.a1{
text-align: center;
width: 50%;
display: block;
line-height: 50px;
color: #000;
font-size: 19px;
list-style: none;
font: #000;
}
.a2{
text-align: center;
width: 50%;
display: block;
line-height: 50px;
color: #222;
float: right;
transition: background-color 0.2s ease;
font-size:19px;
text-decoration: none;
margin-top: -150px;
list-style: none;
}
.frequentmem{
display: block;
height: 100%;
width: 100%;
float: right;
}
.message-right{
margin-right:908px;
background: #fff;
height: 615px;
width:455.5px;
margin-top: 50px;
float: left;
position: fixed;
}
hr{
background: #e9e9e9;
border: 0;
-moz-box-sizing: content-box;
box-sizing: content-box;
height: 1px;
margin: 0;
min-height: 1px;
}
.message{
width: 455.3px;
background: #fff;
height: 50px;
padding: 8px 24px;
}
float:left doesn't do anything if your position is fixed, you should add left:0 instead, on the other hand, you should always specify vertical and horizontal position of a fixed element unless you want it to stay on the part of the page it was rendered this means if your message-right are is rendered below the fold it will not be visible to your users unless you tell it at what coordinates it should remain fixed
I think floating divs and fixing the position do not go well together.
Try removing the float:left and as the user above suggested, adding the left: some_pixels, top: some_pixels to align the div "absolutely" on the page. I usually add a border/background color to divs to identify where they are on the page (then remove later), so you can try that to to make sure it is where you expect it to be.
.message-right{
margin-right:908px;
background: #fff;
height: 615px;
width:455.5px;
margin-top: 50px;
**float: left;** <-- remove
position: fixed;
left: 50px;
top: 50px;
}
With a fixed position, maybe your div is behind some other content. Have you tried using a z-index ? Setting the z-index to 1 would move it forward over another div. Also, you have no top, bottom, right or left dimensions for your fixed position. You could try moving the div around by assigning those values. Example.
Anyways, it is hard to tell what your problem is without the HTML to go with the CSS. Posting that would help you get better response.
I don't have 50 reputation, so I had to add this comment as an answer.
your code looks fine. Adding a border should do the trick.For instance:
But without the rest of the code(html and css) it would be hard to know what is wrong.
.chat-area{
margin-right:908px;
background: #fff;
border:1px solid black;<-- like this
height: 615px;
width:455.5px;
margin-top: 50px;
float: left;
position: fixed;
}