I am trying to make some information sit next to a side panel I have created using Div's.
I have tried to float the text on the left but this hasn't worked.
Here is what I have
Click here
And this is what I want
Click here
I'll show you my page and the style sheet I'm using as well :D
Page:
FitnessHub
<div class="SidePanel">
Text
</div>
<div class="WelcomeText">
</div>
<?php
$db = new mysqli("127.0.0.1", "root", "root", "fitnessbooking");
$query= $db->query("select Username from users where Username = '$_POST[username]' and Pass = '$_POST[password]'");
if ($query->num_rows ==1){
echo "";
}
else {
header("Location: http://localhost/pages/login.php?fail=1");
exit;
}
?>
</body>
</html>
Style Sheet:
.SidePanel {
background-color: white;
width: 250px;
height: 100%;
}
.WelcomeText {
Float left;
}
First, be advised that you code is susceptible to SQL injection attacks. You should be using parameterized queries or at least escaping them.
http://php.net/manual/en/security.database.sql-injection.php
Second, float both items left:
.SidePanel { float: left; }
.WelcomeText { float: left; }
You are missing : in your style,
.WelcomeText {
Float: left;
}
You could remove the float:left and add display: inline-block; to both the side-panel and welcome-text classes.
The default display property for a div is block, which means it would be forced below the sidePanel div.
So a quick way around this is to use the inline-block property.
.SidePanel {
background-color: white;
width: 250px;
height: 100%;
display: inline-block;
}
.WelcomeText {
display: inline-block;
}
Here is a great explanation of why inline-block is now preferable to float: https://stackoverflow.com/a/15177860/5995092
"A huge benefit of display:inline-block is that when other developers are maintaining your code at a later point, it is much more obvious what display:inline-block and text-align:right is trying to accomplish than a float:left or float:right statement." - Alex W.
Related
I try to modify single.php in WordPress theme, by adding social buttons before & after the post contents, as below:
<div class="socialsharebuttons">
<strong>SHARE NOW:</strong><?php echo do_shortcode('[DISPLAY_ULTIMATE_SOCIAL_ICONS]'); ?>
</div>
<div class="entry">
<?php the_content(''); ?>
</div>
<div class="socialsharebuttons">
<strong>SHARE NOW:</strong><?php echo do_shortcode('[DISPLAY_ULTIMATE_SOCIAL_ICONS]'); ?>
</div>
In the code, the "SHARE NOW" text appears right before the PHP code that generate the shortcode. However, after displaying the post such as http://www.sybase-recovery.com/blogs/datanumen-archive-repair-3-8-is-released-on-may-16-2021/, I find the "SHARE NOW" shows AFTER the social buttons, as below:
I then use Chrome DevTools to diagnose the issue, and find the codes are:
<div class="socialsharebuttons">
<strong>SHARE NOW:</strong><div class="sfsi_widget sfsi_shortcode_container">...</div>
</div>
The "SHARE NOW" is also before the <div class="sfsi_widget sfsi_shortcode_container">.
I then check the CSS for , and find it has property float: left. So I follow the instructions in https://stackoverflow.com/a/2417150/2704265 and modify CSS as below:
div.socialsharebuttons {
display: inline-block;
width: 100%;
float: left;
}
But that still not working, why?
This happens because strong is an inline element so it won't respect the preceding floats. In order to make it side by side just set
div.socialsharebuttons strong{
float: left;
margin-top: 13px;
}
After setting this it will looking like this
If you want the list to go after the text use
div.socialsharebuttons strong{
display: block;
margin-bottom: 13px;
}
you want the "share now" in front, or above the social buttons?
For above it's:
.sfsi_shortcode_container {
float: none;
}
In Front:
.sfsi_shortcode_container {
float: right;
margin-left:10px;
}
.socialsharebuttons > strong {
position: relative;
top: 15px;
}
we can see lot of empty space in link as below the image. I want to hide those empty space.
.main {
margin: 0 auto;
width: 1000px;
}
body, button, input, select, table, textarea {
font-family: 'Roboto Condensed', sans-serif;
color: #636363;
font-size: 14px;
line-height: 1.5;
}
html
<div class="custom_case">
<div class="custom_case_left">
<h1 class="cc1">Custom Cases</h1>
<h2 class="cc2">Make Your Own design</h2>
</div>
<?php
$brandSelect = '<select id="brand_select">';
$brandSelect .= '<option value="">My Brand</option>';
$brandSelect .= '</select>';
echo '<select id="model_select"><option value="">My Model</option></select>';
?>
<div class ="cc3">
<div class ="cc4">
<span class ="cc5"> See Cases > </span>
</div>
</div>
I dont want to give so much empty space between image and below footer
please help me for this.
Thanks in advance.
Figured it out for you!
Your image of the phone cases is what is causing the space issue.
.custom_case_right img {
/*float:right;*/
/*bottom:320px;*/
}
That will fix the spacing beneath your image. Now your image is displaying improperly and to fix do this
.custom_case_right {
float:right;
margin-top:-310px;
}
These two changes ought to take care of it for you. I tested this out in Chrome.
You'll still need to think about how you want to have your image behave as your viewport shrinks though.
trying to make img:
line-height: 0;
vertical-align: top or bottom;
You have to fix the height of main-container.
enter code here.main-container{
height:550px;
}
Make this changes to your classes:
.col1-layout .col-main {
position: relative;
}
.custom_case_right {
float: left;
position: absolute;
top: 0;
bottom: 0;
right: 0;
}
And in your image remove position absolute, add this style instead:
.custom_case_right img {
position: relative;
width: 620px;
height: 100%;
}
I've been having trouble with this,I'd like to make a sort of "page navigation" with two links (to go forwards and backwards). On one line, I'd like a link on the far left side, and on the same line, a link on the far right. If the curly braces were the extent of the parent object, it would look something like this:
{Backwards Forwards}
The left side of the left link should be flush with the content boundary (is that what you'd call it? I mean just before padding sets in) and vice-versa.
Thanks.
So many ways to do it... one of them is using inline-block elements, the other one is using floats, etc.
Below are the two examples, the second one featuring a parent-child structure, like you wanted.
div {
display: inline-block;
height: 20px;
width: 300px;
background: #eee;
padding: 20px;
text-align: center;
}
#l {
float: left;
}
#r {
float: right;
}
<a>Backwards</a><div>Content</div><a>Forwards</a>
<br /><br />
<div><a id="l">Backwards</a> Content <a id="r">Forwards</a></div>
float:left to the first one, float:right to the second one.
I do it normally with class names .fl / .fr and and a containing div with a clear:both.
Because of collapsing height of the div use a crossbrowser hack
<style>
/*---------------float / clear-------------*/
.fl {float: left;}
.fr {float: right;}
.clear:after {
content: ".";
display: block;
font-size: 0;
height: 0;
clear: both;
visibility: hidden;
}
.clear {display:inline-block;}
/* Hide from IE Mac \*/
.clear { display:block; }
/* End hide from IE Mac */
* html .clear {height:1px;}
/*---------------clear-------------*/
</style>
<div class="clear">
<a class="fl" href="#">backward</a>
<a class="fr" href="#">forward</a>
</div>
Here is a menu I was working on today actually. You just need to add float: right; to your second <a> tag. Here is my example:
JS Bin
Consider the following:
<a>a</a><a>b</a>
How can I align the second anchor (b) to the right?
PS: float is an abuse in this situation. It's not made for this and it causes some problems, so I need other more reasonable solution.
Just do this:
style="float:right"
Like:
<div>
Equipment
Model
</div>
http://jsfiddle.net/umerqureshi/0jx7kf1L/
You'd need separate containers.
<p>
<span>
<a>Left</a>
</span>
<span class="align-right">
<a>Right</a>
</span>
</p>
p {font-size:0; /* Fixes inline block spacing */ }
span { width:50%; display:inline-block; }
span.align-right { text-align:right; }
span a { font-size:16px; }
JSFiddle example.
Try this CSS,
Using CSS3 nth-child()
a:nth-child(2) {
display: inline-block;
text-align: right;
width: 100%;
}
Demo: http://jsbin.com/opexim/3/edit
Note: nth-child is a CSS3 and won't work on older browsers like IE6, 7 and 8
Support for old browsers
Set class to second <a> anchor element and apply the CSS.
<a>a</a><a class="right">b</a>
a.right {
display: inline-block;
text-align: right;
width: 100%;
}
Maybe you can make something like this: <a>a</a><a class="right">b</a>
And CSS like this:
a.right {
position: absolute;
right: 0;
}
Try and use :nth-child():
a:nth-child(2) {
display: inline-block;
text-align: right;
width: 100%;
}
I don’t know if this works for the older browsers.
Assign a class or id to the 'b' containing anchor and give margin-left:100% to it.
For example:
.second{margin-left:100%;}
or else
a:nth-child(2){margin-left:100%;}
or else
you can also do like mentioned below:
css
a:nth-child(1){display:inline-block;width:50%;text-align:left;float:left;}
a:nth-child(2), .second{display:inline-block;width:50%;text-align:right;}
Working Fiddle
You may try the below code:
<a>a</a><a align="right">b</a>
<a>a</a><a style="text-align:right">b</a>
<div class="mydiv">
<a class ="mylink"> test </a>
</div>
.mydiv {
text-align: left;
}
You must enter your styles for the 'a' tag algin give to 'div'.
Im trying to use padding to push an image 18px from the top of a div. Neither margin or padding are working, and after comparing the two padding seems to be what I want anyway.
The problem is with the footer-middle-left-left-image div tag. The margin on the text one works fine though.
Here's the html:
<div id = "footer-middle-left-left">
<div id = "footer-middle-left-left-picture">
<img src = "" alt = "some_text">
</div>
<div id = "footer-middle-left-left-text">
If you would like to join our newsletter, please enter your </br>
email address below.
</div>
<div id = "footer-middle-left-left-email">
</div>
</div>
The CSS I have is:
#footer-middle-left-left {
float: left;
width: 483px;
height: 175px;
}
#footer-middle-left-left-image {
float: left;
width: 483px;
height: 59px;
padding-top: 18px;
}
#footer-middle-left-left-text {
width: 483px;
height: 58px;
float: left;
margin-left: 25px;
color: white;
}
#footer-middle-left-left-email {
height: 58px;
float: left;
width: 483px;
}
Any help would be appreciated! Also any advice, anything at all would be nice too. I'm pretty new so advice not relevant to my problem is also appreciated, like is this a good id-naming convention, etc..
In html you have footer-middle-left-left-picture but in css #footer-middle-left-left-image
Is it this bug or you just make mistake on paste code?
http://jsfiddle.net/CmwHu/
#footer-middle-left-left-image this id doesnt exist in your html.
So i have changed footer-middle-left-left-picture to #footer-middle-left-left-image.
It is working now
DEMO