Sorry, I feel like making someone else to do my job but I feel really lost here, here's an image of what I got now:
Where the two "Anonomymos" are is ment to be the place for tha active users in the chat, however, the more people I add to the chat the <div> tag where the message is posted goes under the <div> tag for the active users and obviously I want to be shown next to each other.I use a premade CSS style sheet for this, and hope that it could be changed in way to work for my needs, but I have poor knowledge about CSS so I'm not even sure if it is usable in my case, anyways, here is the CSS style that I use at the moment:
#ActiveUsers
{
clear:both;
border: 1px solid #cccccc;
width: 356px;
background: #E9ECEF;
font-family: Arial, Helvetica, sans-serif;
font-weight:bold;
font-size : 12px;
padding:2px;
margin-bottom:10px;
margin-top:10px;
margin-left: 60px;
}
#chat
{
margin: auto;
border: 1px solid #cccccc;
width: 356px;
background: #E9ECEF;
text-align:left;
font-family: Arial, Helvetica, sans-serif;
font-weight:bold;
font-size : 12px;
padding:2px;
height:400px;
overflow:auto;
}
#main {
margin: auto;
border: 1px solid #cccccc;
width: 600px;
min-height:150px;
background: #F1F3F5;
font-family: Arial, Helvetica, sans-serif;
font-weight:bold;
font-size : 12px;
border-collapse:collapse;
}
#sender
{
margin-left: 125px;
}
And here is the structure in the .php file :
<div id="main">
<div id="ActiveUsers"></div>
<div id="chat"></div>
<div id="sender">
Your message: <input type="text" name="msg" size="30" id="msg" />
<button onclick="doWork(document.getElementById('msg').value);">Send</button>
</div>
<span id="logOut">
<form action="logout.php">
<input type="submit" value="Logout"/>
</form>
</span>
</div>
P.S Just to mention, now the #ActiveUsers width is more than the free space but even if I make it 30px, the #chat <div> still goes under and under with every new user that is logged.
The issue might be that your Active Users are wrapped in some block-element when they are dynamically added to your markup. Based on how it is displayed, I'm guessing that
<div id="ActiveUsers"></div>
turns into
<div id="ActiveUsers"><div>Anonymos</div> <div>Anonymos</div></div>
Check to see if your active users are wrapped by any tag. If they're wrapped with a <div> tag, you'll need to add this to your CSS:
#ActiveUsers div {
display: inline;
.
. /* Your styles here */
.
}
Related
I try to bring input fields in to the centre of the page. For some reasons the padding that I have set for the input fields moves them to right and I don't want this. Could please somebody help me to fix this? Here is the code.
.BeWeird_register_container {
display: flex;
justify-content: center;
}
.BeWeird_register_wrapper {
width: 60%;
}
input[type=text],
select {
border: none;
width: 100%;
padding: 30px 20px;
margin: 8px 0;
display: inline-block;
background-color: #000;
color: #BBFB34;
font-family: Gotham, "Helvetica Neue", Helvetica, Arial, "sans-serif";
font-size: 1.2vw;
}
<div class="BeWeird_register_container">
<div class="BeWeird_register_wrapper">
<div class="BeWeird_login_wrapper">
<div class="login_image"><img src="Images/LoginImage.png" alt="" /></div>
<form method="post" action="BeWeird_login.php">
<?php include('errors.php'); ?>
<div class="login_form_wrapper">
<div class="input-group">
<input class="login" type="text" placeholder="Username" name="username">
</div>
<div class="input-group">
<input class="login" type="password" placeholder="Password" name="password">
</div>
<div class="input-group">
<button class="login" type="submit" class="btn" name="login_user">Login</button>
</div>
</form>
</div>
</div>
</div>
Help would much appreciated. Thanks for in advance.
In my opinion, you put display: flex in styles of the wrong container.
You want to center the DOM of login_form_wrapper.
Remember that flex-direction is set to row` as default.
Here's a nice explanation of how to use flex.
A Complete Guide to Flexbox
Correct me if I am wrong but as far as I understand that's what you are looking for:
JsFiddle
David
To center inputs in your form, add style="text-align:center;" to the parent element that contains the inputs, in this case that is the login_form_wrapper class.
Also, if you check the boxes in the browser (F12), you will see that the div BeWeird_login_wrapper shows larger than it should be. For simplicity, just make use of the structure above this heading MDN web docs and nest the divs.
thanks for your help guys. The code was fine. It just needed in the input css code box-sizing:border-box;
like this:
input.login[type=text], select {
border:none;
width: 100%;
padding: 30px 20px;
margin: 8px 0;
box-sizing:border-box;
background-color: #000;
color:#FEA6E5 !important;
font-family:Gotham, "Helvetica Neue", Helvetica, Arial, "sans-serif";
font-size:1.2vw;
}
You can mention use:
outer-element{
display:flex;
justify-content:center;
align-items:center;
}
I have an HTML tag like below :
<div id="Code_G" class="editor-group">
editor-group<br />
<div id="Code_L" class="editor-label ">
editor-label
</div>
<div id="Code_F" class="editor-field ">
editor-field
</div>
</div>
I must give style with CSS to this tags without any changing in the HTML tags to make an input like below picture. The id="Code_F" must be converted to an input tag. How can I do this only with CSS ?
The most important thing is that this job must be done without any adding element to the HTML tags or any direct changing in the HTML tags and all the changes must be done with CSS!
Any help will be appriciated!
No, you can use the css content property to generate / replace content like this.
p:after {
content: "lorem";
}
If you want to alter the html, you would have to use javascript.
There is not a way you could programmatically create/delete/replace DOM elements using using HTML/CSS. Such requires Javascript, or creating the elements manually, even the pseudo elementlike after can only do so much since there is no way you could add a working input inside the content property, here is a way you could use in javascript
<!DOCTYPE html>
<html>
<body>
<p>Click the button to create a basic input field</p>
<button onclick="myFunction()">create</button>
<script>
function myFunction() {
var x = document.createElement("INPUT");
x.setAttribute("type", "text");
x.setAttribute("value", "this is a simple input");
document.body.appendChild(x);
}
</script>
</body>
</html>
#Code_G {
font-family: Arial, Helvetica, sans-serif;
font-size: 14px;
font-weight: 700;
line-height: 1;
color: #d9d3d3;
text-align: center;
position: relative;
}
#Code_L {
position: absolute;
right: 15px;
top: 16px;
background: #fff;
padding: 0 10px;
color: #000;
}
#Code_F {
min-height: 46px;
box-sizing: border-box;
border: 1px solid #ced4da;
border-radius: 4px;
padding: 15px 15px 10px 15px;
font-size: 16px;
font-weight: 400;
color: #495057;
text-align: right;
margin-top: 8px;
}
<div id="Code_G" class="editor-group">
editor-group<br />
<div id="Code_L" class="editor-label ">
editor-label
</div>
<div id="Code_F" class="editor-field ">
editor-field
</div>
</div>
You can use fieldset and legend for this purpose.
legend {
text-align:right
}
.output {
font: 1rem 'Fira Sans', sans-serif;
}
input {
border:none;
width:100%;
outline:none;
}
fieldset {
border-radius:5px;
width:400px;
}
input::placeholder {
text-align:right
}
<div>
<fieldset>
<legend>editor-field</legend>
<input type="text" id="monster" name="monster" placeholder="editor-field">
</fieldset>
</div>
Hello I really need your help. I have been googling around for how to make a tweet box like twitter's "What's happening" box for user to post new content using bootstrap 3 but so far I cannot find anything close.
Anyone have any idea or keyword that could help? Thank you very much!
You may find a lot of plugins to do the same . But If you want do it your own follow the below steps (this contain only basic functionality)
Define a span or div like below
<div class="container">
<div id="mockTextBox">
What's Happening ?
</div></br>
<textarea id="originalTextBox" class="form-control">
</textarea>
</div>
Hide the textarea at first and show the span/div as textbox.
Then define the events
$(document).ready(function(){
$('#originalTextBox').hide()
$('#mockTextBox').click(function(){
$('#mockTextBox').hide()
$('#originalTextBox').show()
})
})
Apply CSS accordingly and you got what you want.
#mockTextBox
{
width:300px;
height:50px;
border:1px solid;
}
#originalTextBox
{
width:300px;
height:50px;
resize:none;
}
Check this sample http://codepen.io/Midhun052/pen/mVByzK
I have add the bootstrap class to text area in the codepen above for that nice look.
Just updated
A few more CSS and Images
$(document).ready(function() {
$('#originalTextBox').hide()
$('#mockTextBox').click(function() {
$('#mockTextBox').hide()
$('#originalTextBox').show()
})
})
#mockTextBox
{
width:300px;
height:50px;
border:1px solid;
display:inline-block;
margin-top:10px;
border: 1px solid #337ab7;
}
#txt
{
border:1px solid;
display:inline;
height:20px;
}
#originalTextBox
{
width: 310px;
height: 100px;
resize: none;
border: 1px solid #337ab7;
background-color: #337ab7;
margin: 10px;
}
#originalTextBox textarea
{
resize:none;
margin:5px;
width:300px;
}
.class2
{
float: right;
margin-top: 12px;
margin-right: 2px;
}
.imgF1
{
width:20px;
height:20px;
margin:5px
}
<link href="http://maxcdn.bootstrapcdn.com/bootstrap/3.3.5/css/bootstrap.min.css" rel="stylesheet"/>
<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.10.0/jquery.min.js"></script>
<div class="container">
<div id="mockTextBox">
<img src="http://lorempixel.com/46/46"/>
<div id="txt">What's Happening ?</div>
<img class="class2" src="http://lorempixel.com/16/16"/>
</div>
<div id="originalTextBox">
<textarea class="form-control">
</textarea>
<img class="imgF1" src="http://lorempixel.com/46/46">Post your photo</img>
</div>
</div>
It's simple jQuery application.
Check this out.
Here's a JSFiddle.
Then all you gotta do is initiate the jQuery.
Such as:
$('textarea').autogrow({onInitialize: true});
Check fiddle for more info.
Cheers!
UPDATED ANSWER:
Use CSS to style your textarea, no need for javascrcipt styling here. Prepare your style in CSS under a specific class and when you need to, you can add your element this class and its propeties. This is much cleaner solution. Use focus and blur events to get textarea element. Here is example.
HTML
<textarea rows="4" cols="50" id="txtArea">
<textarea>
JS
$(document).ready(function() {
$('#txtArea').on("focus", function(event) {
if(!$('#txtArea').hasClass('customTextAreaClass')){
$('#txtArea').addClass('customTextAreaClass');
}
});
$('#txtArea').on("blur", function(event) {
if($('#txtArea').hasClass('customTextAreaClass')){
$('#txtArea').removeClass('customTextAreaClass');
}
});
});
CSS
.customTextAreaClass{
background-color: #fff;
width: 565px;
color: #000;
height: 120px;
padding-left: 1px;
padding-top: 1px;
font-family: "Tahoma", Geneva, sans-serif;
font-size: 10pt;
border: groove 1px #e5eaf1;
position: inherit;
text-decoration: none;
}
I have a search box like below and i am using bootstrap to give a flexible layout. How can use a design like below and make sure i can get a stretchable search box.
You'd need a container to put your input box in, and put a front and end div to it. Depending on browser compatibility you might want to add a few more div's to make sure your input box is shown properly in browsers like IEX7/8 though.
So you'd have the following:
<form class="searchbox">
<input type="text" class="text" />
<input type="submit" class="submit" />
</form>
Accompanied by the following example CSS
form.searchbox { background:url(leftside_image.gif) 0 0 no-repeat; padding-left:15px; }
form.searchbox input.text { border:none; border-top:1px solid #999; border-bottom:1px solid #999; height:25px; line-height:25px; padding:0 5px; }
form.searchbox input.submit { background:url(rightside_image.gif); }
Add your Html part like this
<div class="searchbox">
<input class="lightsearch" type="text" name="s" onfocus="doClear(this)" value="">
</div>
css part, download a search box image and replace it with the name
.searchbox input.lightsearch {
background: url("images/lightsearch.png") no-repeat scroll 0 0 transparent;
border: 0 none;
color: #575757;
font-size: 11px;
height: 19px;
margin-top: 24px;
padding: 2px 5px 2px 24px;
width: 170px;
}
Everything is working fine on my default resolution; however, when I run my website on another resolution everything goes to the right instead of center. Why is this? I have tried setting the overflow to 0%.
Here is the HTML file:
<html>
<head>
<script type="text/javascript">
</script>
<link rel="stylesheet" type="text/css" href="stylesheet.css" media="screen"/>
<body>
<div id="banner">
<h2 id="bannertext"> Websites4u </h2>
</div>
<div id="buttonbar">
<a id="homeb" href="webpageone.html">Home</a>
<a id="aboutb" href="fake.html">About</a>
<a id="contactb" href="webpage2.html">Contact Us!</a>
</div>
<div id="mainbody">
<p id="radio">
3gb: <input type="radio" name="age" value ="<3gb"> <br> <br>
4gb: <input type="radio" name="age" value ="4gb"> <br> <br>
8gb: <input type="radio" name="age" value ="8gb"> <br> <br>
16gb: <input type="radio" name="age" value ="16gb"> <br>
</p>
<h4 id="bodytext"> Please Select Your Hardware </h4>
<h3 id="Ram"> Ram </h3>
</div>
</body>
</html>
Here is the CSS:
*{
margin:0;
padding:0;
}
h1 {
color:blue;
}
body{
width:1280px;
height:720px;
background-image:url("background colour.jpg");
overflow:hidden;
}
#banner{
position: relative;
height: 50px;
width: 148%;
border: medium solid BFBDBA;
background-color:F1C43E;
margin:0 auto;
}
#bannertext{
color:white;
text-align:center;
font-family:Comic Sans MS, cursive, sans-serif;
margin:0 auto;
}
#buttonbar {
position: relative;
height: 30px;
width: 148% ;
border: medium solid BFBDBA;
background-color:lightgrey;
color:white;
margin:0 auto;
font-family:Comic Sans MS, cursive, sans-serif;
font-style:bold;
}
#homeb {
position: relative;
left: 450px;
}
#aboutb{
position: relative;
left: 500px;
}
#contactb{
position: relative;
left: 550px;
}
a {
color: white;
font-weight:bold;
}
a:hover {
COLOR: orange;
font-weight:bold;
}
#bodytext{
position: relative;
top:50px;
left:50px;
color:red;
font-size:35px;
margin:0 auto;
font-family:Comic Sans MS, cursive, sans-serif;
}
#mainbody{
position: relative;
background-color: white;
height: 1000px;
width: 80%;
left: 30%;
top: 5px;
border:medium solid F1C43E;
}
#radio{
position: absolute;
top: 240px;
left:100px;
font-size: 18px;
margin:0 auto;
}
#Ram{
position: absolute;
top: 176px;
left: 100px;
font-size: 30px;
color: Green;
margin:0 auto;
font-family:Comic Sans MS, cursive, sans-serif;
}
Hard to fix all your issues quickly. Your basic mistake is that you have absolute values for every item.
For instance:
body{
width:1280px;
height:720px;
background-image:url("background colour.jpg");
overflow:hidden;
}
Because of width specified there, your content will always have width of 1280px when you open it on a screen with smaller width it will be still rendered with width of 1280px and because of overflow:hidden you will see it simply like it is shifted to the right side. When you do something with computer it will do not what you WANT, but what you ask it to do. And overflow:hidden simply hide everything outside of visible area, not center content like you want.
For #buttonbar:
#buttonbar {
position: relative;
height: 30px;
width: 148% ;
border: medium solid BFBDBA;
background-color:lightgrey;
color:white;
margin:0 auto;
font-family:Comic Sans MS, cursive, sans-serif;
font-style:bold;
}
- even have no idea why do you need width:148% here. Buttons inside it are centered with absolute positions:
#homeb {
position: relative;
left: 450px;
}
left:450px strictly says to browser: hey, put this #homeb on the 450th px inside its parent block. And browser will do it like that and will not shift it to little more left because you want it to be centered.
You may tell him to place all buttons in center:
#buttonbar {
height: 30px;
text-align:center;
border: medium solid BFBDBA;
background-color:lightgrey;
color:white;
margin:0 auto;
font-family:Comic Sans MS, cursive, sans-serif;
font-style:bold;
}
text-align:center; - this will tell browser to center content inside of #buttonbar not depending on its width, and no need to define classes for #homeb, #aboutb and #contactb.
And so on. There are to many places to fix. I gave you a starting point. Here is demo with some changes already done for you: http://jsfiddle.net/2rM6K/7/
You just need to understand what each line of your code means for browser if you want to get something working correctly. If you do not understand how something works - there is a lot of info in web and people are ready to help you. Just do not expect that some magic happens while you writing a code - you must learn how things work. Read, try, experiment, read again, try again, experiment again until you start understanding why and how something works.
page
{
Margin-right:auto;
margin-left:auto;
width:800px;
}
u can change width according to your requirement.