Basically, I am coding a simple page and on desktop, it all aligns just fine. When switched over to mobile it appears very differently. I will include screenshots to show what I mean. I have tested this on Nexus 5, iPhone 6, iPad Air and two different desktop monitors (21in + 17in).
How would I go about fixing this exactly? I am not very advanced in bootstrap but I couldn't find anything in the documentation about mobile.
Also, the alignment of things and their position changes based on size of monitor. Even if I zoom out it will change the position of things and make it look weird.
I guess what I'm wondering is how to make this page more repsonsive!
Here is the code for the section:
<div class="well" style="height:12%;width:75%;">
<div class="col-md-10">
Testing12332<br /><br /><a class="link" href="view.php?id=27"><b>Testingthis</b> - 0 seconds</a>
</div>
<div class="col-md-2">
<form action="like.php?id=27" method="POST" style="margin-bottom:0px;margin-top:-8%;">
<button class="btn btn-primary btn-sm" type="submit" name="submit" id="submit">▲</button><br />
<input type="hidden" name="id" value="27">
</form>
<div class="well" style="padding:0px;margin-bottom:0px;">
0
</div>
<form action="dislike.php?id=27" method="POST">
<button class="btn btn-primary btn-sm" type="submit" name="submit" id="submit">▼</button><br />
<input type="hidden" name="id" value="27">
</form>
</div>
</div>
Let me know if more information is needed! I tried to provide as much as possible! Also, yes, I am using Bootswatch (Flatly) if that makes a difference.
Edit: All of the code is here --> http://pastebin.com/AvYEkDNN
Sorry for the format being messed up, a lot of it is output with PHP and messed up the format in each loop.
Here's a link to your complete HTML. http://pastebin.com/ZCvDzz3b The only other thing you need to do is create an external stylesheet if you don't already have one called style.css and then add this code at the bottom of this sheet. Make sure your style.css is placed in the same location as your index file.
#media (min-width:768px) {
.well {width:75%!important;
height:22%!important;
}
}
OK, I have found the issue thank you to your comment
First of all, do NOT use inline styling. It usually means problems and quite rarely a solution.
With that in mind, get rid of this:
<form action="like.php?id=27" method="POST" style="margin-bottom:0px;margin-top:-8%;">
and replace it by
<form action="like.php?id=27" method="POST" class="my-custom-form">
this will allow you to re-use that style every time.
Now you can do something like this by simply adding some EXTERNAL CSS:
.my-custom-form{margin-bottom:0px;margin-top:-8%;}
/** add some styling for small devices **/
#media handheld, only screen and (max-width: 767px) {
.my-custom-form{margin-bottom:0px;margin-top:1% /* or whatever, just not a negative value */;}
}
and it will fix your issue
EDIT:
Besides the above, clean your code like this:
<div class="well row-fluid">
<div class="col-md-10">testingthis
<br />
<br /><a class="link" href="view.php?id=28"><b>Anonymous</b> - 27 minutes ago</a>
</div>
<div class="col-md-2">
<form action="like.php?id=28" method="POST" class="my-form">
<button class="btn btn-primary btn-sm" type="submit" name="submit" id="submit">▲</button>
<br />
<input type="hidden" name="id" value="28" />
</form>
<div class="number">-1</div>
<form action="dislike.php?id=28" method="POST">
<button class="btn btn-primary btn-sm" type="submit" name="submit" id="submit">▼</button>
<br />
<input type="hidden" name="id" value="28" />
</form>
</div>
<div class="clear clearfix"></div>
</div>
and also get rid of your element. With all these changes (plus any additional visual adjustment you may need), it will work on all sizes
Related
So I have this code:
<form action="{{ url_for('profile') }}" method="post" enctype=multipart/form-data>
<label for="files" class="btn btn-light btn-sm">Cambiar foto de perfil</label>
<input id="files" style="visibility:hidden;" name="photo" type="file" required>
<input type="file" accept="image/*">
<label for="submit" class="btn btn-light btn-sm">Actualizar</label>
<button style="visibility:hidden;" id="submit" type="submit"> Actualizar </button>
</form>
I would like to know how to eliminate the space between these labels. I have tried with Margin="0" and nothing happened.....Thanks in advance.
Are you referring to the space to the right of "Cambiar foto de perfil"? If so, that's due to the adjacent input being styled with visibility: hidden. If you want that input to be hidden AND not take up any space, you would need to set it to Display: none instead of the visibility property.
Not quite sure what you want to achieve - assuming you want to have a form with 3 lines of input widgets, 2 file uploaders and a submit button, you may want to start off with something along these lines:
<form action="{{ url_for('profile') }}" method="post" enctype=multipart/form-data>
<div>
<label for="files" class="btn btn-light btn-sm">Cambiar foto de perfil:</label>
<input id="files" style="visibility:visible;" name="photo" type="file" required>
</div>
<div>
<div>
<label for="images" class="btn btn-light btn-sm">Cambiar el fichero del fotos:</label>
<input id="images" type="file" accept="image/*">
</div>
<div>
<label for="submit" class="btn btn-light btn-sm">Actualizar:</label>
<button style="visibility:visible;" id="submit" type="submit"> Actualizar </button>
</div>
</form>
Modifications in above code snippet:
Wrap each widget and its label in a div element.
Make the widgets visible
Add a label for the image uploader
Further suggestions:
Add a full-fledged css layout (flex or grid) to align widgets and labels.
Add Css styles to the divs and toggle the display property to selectively add or remove widgets ( beware, usually considered bad user interface design ).
The MDN Web Docs (previously Mozilla Developer Network, MDN) is an excellent resource for learning about web technologies. You may want to hav a look at the CSS section, in particular the CSS layout tutorial.
I'm running into issues with modals and forms with Foundation.
I want to be able to fill out a form, open a modal, then have that modal be able to submit the form.
Normally, I'd have my form, and all of it's form fields, and put the modal inside the the form element, and that would be fine - but with foundation, I find that the reveal modal is moved to the bottom of the DOM.
What's the best way to accomplish what I'm after?
I've added a skeleton of what my normal structure might be like - any help would be greatly appreciated.
<form method="post" action="...">
<label for="title">Title</label>
<input type="text" name="title" id="title" placeholder="Enter campaign title here" required>
<label for="title">Description</label>
<textarea type="text" name="description" placeholder="Description of this campaign"></textarea>
<button type="button" class="button default-btn float-right" data-open="emailSendConfirmation">Publish campaign</button>
<div class="reveal" id="emailSendConfirmation" data-reveal>
<button data-close aria-label="Close modal" type="button" class="button">Cancel</button>
<button type="submit" class="button" name="status" value="Published">Publish</button>
</div>
</form>
Thanks,
Ollie
I am using a template, the name is Treble One Page Rsponsive Theme from Wrapbootstrap which uses Twitter Bootstrap. I am implementing the template and encountered this small error which drove me crazy.
There is a search bar, consists of <input> tag and <button> tag. Previously it was fine, until I make it inside a <form>, the search bar started to act weird. The <input> field is centered, but the <button> appended into outside the field making the whole things uncentered.
Here is the image, to be clear:
picture
And here is my code:
<div class="row">
<div class="span8 offset2">
<div class="input-append">
<form method="get">
<input class="span5" id="appendedInputButton" type="text" placeholder="Search By Name" name="searchTerm" value="Search">
<button class="btn btn-primary sicon-search sicon-white" type="submit"><i>Search</i></button>
</form>
</div>
</div>
</div>
I've googled this template.
This code works on original template as expected:
<div class="row">
<div class="span8 offset2">
<form class="input-append" method="get">
<input class="span5" id="appendedInputButton" type="text" placeholder="Search By Name" name="searchTerm" value="Search" />
<button class="btn btn-primary sicon-search sicon-white" type="submit"><i>Search</i></button>
</form>
</div>
</div>
Main idea is to convert "input-append" div into form, instead of adding new form element within it.
I have a text input element and a submit input element that I need to be inline and responsive. The problem is that I can't find a way to get the text input element to be fluid without screwing up the positioning of the button. Any help would be appreciated.
Here is the html structure I'm using.
<div class="search-call-to-action">
<form action="#">
<input type="text" name="search" placeholder="Search charities by keyword or name...">
<input class="btn btn-primary btn-large" type="submit" name="submit" value="Search">
</form>
</div>
Here is a screenshot of what I am trying to achieve. The text input needs to be fluid.
http://i.imgur.com/Ivty5Qq.png
I have provided a jsfiddle with a working demo on how to achieve this. It uses the overflow property. Demo http://jsfiddle.net/kevinPHPkevin/vbdy9/
<form action="search.php" method="get">
<input type="submit" name="search" value="Go" style="float: right" />
<div style="overflow: hidden; padding-right: .5em;">
<input type="text" name="term" style="width: 100%;" />
</div>
</form>
You can use media queries to achieve this. Then you should create queries for each resolution. Example:
#media (min-width: 320px){
div
{
//some propererties in ems
}
The following code example code should result in something like .
<form class="well form-search">
<div class="pull-right">
<div class="input-prepend">
<span class="add-on">
<i class="icon-search"></i>
</span>
<input type="text" class="input-large search-query" />
</div>
<button class="btn" type="submit">Search</button>
</div>
</form>
This works perfectly well in Firefox, but in both Chrome and Internet Explorer 7 browsers, it looks like the following:
Am I doing something "illegal" with bootstrap? I did not make any adaptions yet so it's completely out-of-the-box.
Any help is greatly appreciated!
This was a reported issue: https://github.com/twitter/bootstrap/issues/1362
The fix outlined by tonybolzan in the issue works best because you don't have explicitly set a width:
.input-prepend, .input-append {
white-space: nowrap;
-webkit-padding-end: 27px;
}
The problem is with the whitespace found in your markup, try to place the span tag on the same line as the input, like so:
<form class="well form-search">
<div class="pull-right">
<div class="control-group">
<div class="input-prepend">
<span class="add-on"><i class="icon-search"></i></span><input type="text" class="input-large search-query" />
</div>
<button class="btn" type="submit">Search</button>
</div>
</div>
</form>
This is old, but it helped me determine the answer I was looking for:
The problem is probably that bootstrap is setting the width of the input to 210px, which is causing the whole icon/input/button grouping to be wider than your well.
I've updated the fiddle Andres posted above with a sample of the problem by forcing the well forms to a smaller width than their default and a fix by using an input class with a smaller width.
http://jsfiddle.net/dDtUg/2/