Change style inline to css - html

I have these form with style inline, but I can't use it in css because it changes all my code when I reference css in another views:
<style>
body {
background: url('http://digitalresult.com/') fixed;
background-size: cover;
padding: 0;
margin: 0;
}
.form-login {
background-color: #EDEDED;
padding-top: 10px;
padding-bottom: 20px;
padding-left: 20px;
padding-right: 20px;
border-radius: 15px;
border-color:#d2d2d2;
border-width: 5px;
box-shadow:0 1px 0 #cfcfcf;
opacity: 0.8;
}
h4 {
border:0 solid #fff;
border-bottom-width:1px;
padding-bottom:10px;
text-align: center;
}
.form-control {
border-radius: 10px;
}
.wrapper {
text-align: center;
}
</style>
#using (Html.BeginForm("Login", "Account", new { ReturnUrl = ViewBag.ReturnUrl }, FormMethod.Post, new { #class = "form-horizontal", role = "form" }))
{
#Html.AntiForgeryToken()
#Html.ValidationSummary(true, "", new { #class = "text-danger" })
<div class="container" style="margin-top:40px">
<div class="row">
<div class="col-sm-6 col-md-4 col-md-offset-4">
<div class="panel panel-default form-login">
<div class="panel-heading">
<strong> Press to continue</strong>
</div>
<div class="panel-body">
<form role="form" action="#" method="POST">
<fieldset>
<div class="row">
</div>
<div class="row">
<div class="col-sm-12 col-md-10 col-md-offset-1 ">
<div class="form-group">
<div class="input-group">
<span class="input-group-addon">
<i class="glyphicon glyphicon-user"></i>
</span>
#Html.TextBoxFor(m => m.Email, new { #class = "form-control has-success", #autofocus = "autofocus", placeholder = "Usuario", required = "required" })
#Html.ValidationMessageFor(m => m.Email, "", new { #class = "text-danger" })
</div>
</div>
<div class="form-group">
<div class="input-group">
<span class="input-group-addon">
<i class="glyphicon glyphicon-lock"></i>
</span>
#Html.TextBoxFor(m => m.Password, new { #class = "form-control has-success", placeholder = "Password", type = "password", required = "required" })
#Html.ValidationMessageFor(m => m.Password, "", new { #class = "text-danger" })
</div>
</div>
<div class="form-group">
<button class="btn btn-lg btn-primary btn-block" type="submit">Login</button>
</div>
<p>#Html.ActionLink("Return to home page", "Index", "Home")</p>
</div>
</div>
</fieldset>
</form>
</div>
</div>
</div>
</div>
</div>
I think the problem is if I send body class to css it changes on all pages I reference css, how can I change to only change in this view? Regards

Instead of changing in file, you may add style in page through tag or give inline style with style element if you need change only at one place.
But adding inline style should be avoided.
Better to differentiate your element with a id and give properties to it

In that case you can save above inline CSS into separate CSS file and import that css file to that HTML page where you want this CSS.

Add the background to container, or add another class to the container and apply the style. and change margin-top to padding-top
.container {
background: url('http://digitalresult.com/') fixed;
background-size: cover;
padding: 0;
margin: 0;
height: 100vh;
padding-top:40px;
}

you can create a CSS file with the styles you mentioned in your view and import that file only in this view which will solve your problem.

Related

How to use an unordered list to display labeled inputs with customized checkboxes using only CSS and HTML?

I want to make a hidden context menu to display multiple genre selections. I want to customize the input checkboxes so that it looks like this:
this image is my required finished layout
It works fine without the label elements in the unordered list elements, however I need the label to toggle the checkbox. This is my current (incorrect) layout:
this image is what I have achieved so far
I have tried many things, including setting:
position: relative/absolute
display: flexbox/inline-block
widths and heights
How do I use an unordered list to display labeled inputs with customized checkboxes using only CSS and HTML?
<div class="col-md-12 col-lg-4 text-lg-right mt-md-4 mt-lg-0">
<div class="d-flex-column w-100" id="genre-bar">
<!-- always visible selections bar -->
<div class="row">
<div class="col-12 mb-3 d-flex text-align-right">
<span class="w-100 genre-bar-display text-align-right align-items-center"><i class="fas fa-chevron-down"></i></span>
</div>
</div>
<div class="genre-hidden-section px-3">
<!-- Multiple selector -->
<div class="row">
<div class="col-6 text-left">
<ul id="first-genre-list" class="genre-list">
<!-- This is populated by the #foreach below using JS -->
</ul>
</div>
<div class="col-6 text-left">
<ul id="second-genre-list" class="genre-list">
<!-- This is populated by the #foreach below using JS -->
</ul>
</div>
</div>
</div>
</div>
<!-- This div gets emptied and removed by JS immediately -->
<div id="select-close-books-genre" style="display:none;">
<ul>
#foreach (GenreModel genre in Model.Genres)
{
<li class="genre-checkbox-container">
<label>
#genre.Name
<span class="genre-checkmark"></span>
<input type="checkbox" value="#genre.Id">
</label>
</li>
}
</ul>
</div>
</div>
li input {
position: absolute;
opacity: 0;
cursor: pointer;
height: 0;
width: 0;
}
.genre-checkmark {
display: inline-block;
top: 0;
left: 0;
height: 13px;
width: 13px;
border: 1px black solid;
border-radius: 3px;
background-color: white;
}
.genre-list {
display:flex;
flex-wrap:wrap;
}
.genre-checkbox-container {
flex-grow: 1;
}
.genre-checkbox-container:hover span {
background-color: #ccc;
}
.genre-checkbox-container input:checked ~ .genre-checkmark {
background-color: #30d9c8;
}
const genreListDiv = $("#select-close-books-genre")[0];
const genreList = Array.from(genreListDiv.firstElementChild.children);
genreListDiv.remove();
console.log(genreList)
for (let i = 0; i < genreList.length/2; i++) {
$('#first-genre-list')[0].appendChild(genreList[i]);
};
for (let i = Math.ceil(genreList.length/2); i < genreList.length; i++) {
$('#second-genre-list')[0].appendChild(genreList[i]);
};
// Open and close the genre selector box
$("#genre-bar").on('click', function(event) {
$("#genre-bar").addClass("genre-bar-open");
$('body').on('click', function () {
$('#genre-bar').removeClass("genre-bar-open");
});
$('#genre-bar').on('click', function (event) {
event.stopPropagation();
});
});

Why doesn't the TextArea allow me to expand it wider

Basically as you can see in the code I tried to set it to 1000px wide just to show its not changing the size at all it wont go any bigger I can make it smaller but not wider. I added some spacing so you can see what I am talking about easier.
The Snippet asked for
#Html.TextAreaFor(x => x.businessJustification, new { id = "businessJustification", name = "businessJustification", #cols = 40, #rows = 3,#style="width: 1000px;"}) </p>
Original Code
#{
ViewBag.Title = "Software Request";
}
#model project1.Model.TicketModel
<head>
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/animate.css/4.1.1/animate.min.css" />
</head>
<body style="background-color:#D1D3D4;"></body>
<div class="jumbotron" style="background-color:#D1D3D4;">
<img src="/Images/TECH_BARlogoBLACK.png" style="width:1000px;height:200px;" class="animate__heartBeat">
<p class="lead" span style="background-color: #FFFF00;">Software Request</p>
<br>
#using (Html.BeginForm(FormMethod.Post))
{
<p class="text-left"><b>Enter Computer Name:</b></p>
#Html.TextBoxFor(x => x.computerName, new { id = "computerName", name = "computerName"})
<p style="font-size: 14px; text-align: left;"><b>To obtain your Computer Name: </b>Click Start (bottom left windows icon) and type in System Information, On the 5th line, your Computer Name is listed as the System Name <br></p>
<p class="text-left" style="width: 1000px;"><b>Business Justification:</b> <br>
#Html.TextAreaFor(x => x.businessJustification, new { id = "businessJustification", name = "businessJustification", #cols = 40, #rows = 3,#style="width: 1000px;"}) </p>
<label for="Software">Select the Software(s) you need!</label>
<br>
#Html.DropDownListFor(model => #Model.selectedSoftwareList, new MultiSelectList(Model.softwareList, "Text", #Model.selectedSoftwareList),
new
{
id = "_SelectedSoftwareList",
#class = "form-control multiselect-dropdown",
multiple = "true",
style = "width:200px;height:300px;",
data_placeholder = "Select Software"
})
<br>
<br><button type="submit" class="btn-primary btn-lg" style="font-size: 20px">Submit</button>
}
</div>
<style>
h1 {
text-align: center;
}
p {
text-align: center;
}
.buttonBig {
display: block;
width: 10%;
border: none;
font-size: 24px;
cursor: pointer;
text-align: center;
}
</style>
I have provided a image of how small the "1000px" wide box is and if I set this to like 200px it is also the same size.

text-align:center is not working on Apps Script HTML sidebar

So I am making an HTML sidebar in Google Sheets using Apps Script. I am also using the Skeleton CSS framework.
So I'd like the submit button here to be centered:
I've tried this: making an align class in CSS, and then applying it to the button. I forgot to mention that all my other elements are aligned except the buttons.
<style>
body{
background-color: white;
color: black;
}
.align{
text-align: center;
}
.margin{
margin-bottom: 10px;
}
h1{
font-size: 20pt;
}
h2{
font-size: 16pt;
}
</style>
Here is my HTML code:
<body>
<h1 class = "align ">Welcome to the clothing expense custom menu bar!</h1>
<h2 class = "align">Here are the custom functions you can use:</h2>
<p class = "align"> See how much you've spent on a brand.</p>
<form onsubmit="runFunc()">
<input class = "u-full-width " id="brand" type = "text" placeholder="Enter brand name">
<div>
<button type="submit" class="button-primary align">Submit</button>
</div>
</form>
<p class = "align"> See how much you've spent on a type of clothing.</p>
<form onsubmit="runFuncTwo()">
<input class = "margin u-full-width" id="type" type = "text" placeholder="Enter clothing brand">
<div>
<button type="submit" class="button-primary align">Submit</button>
</div>
</form>
</body>
Thanks!
All of these 3 solutions should work, I would choose the second or third one.
If you make the div full-width and add align to it, it should work
<div class="u-full-width align">
<button type="submit" class="button-primary">Submit</button>
</div>
You can also make the div a flex, like so (Use classes instead of inline style)
<div class="u-full-width" style="display:flex; justify-content: center">
<button type="submit" class="button-primary">Submit</button>
</div>
You can also add margin:auto and float:none to the button (Use classes instead of inline style)
<button type="submit" class="button-primary"
style="margin:auto; float:none">Submit</button>
The code is:
button.button-primary.align {
width: 100%;
max-width: 150px;
margin: 0 auto;
display: block;
}
And here it is in action:
body{
background-color: white;
color: black;
}
.align{
text-align: center;
}
.margin{
margin-bottom: 10px;
}
h1{
font-size: 20pt;
}
h2{
font-size: 16pt;
}
/*new code from here*/
button.button-primary.align {
width: 100%;
max-width: 150px;
margin: 0 auto;
display: block;
}
<body>
<h1 class = "align ">Welcome to the clothing expense custom menu bar!</h1>
<h2 class = "align">Here are the custom functions you can use:</h2>
<p class = "align"> See how much you've spent on a brand.</p>
<form onsubmit="runFunc()">
<input class = "u-full-width " id="brand" type = "text" placeholder="Enter brand name">
<div>
<button type="submit" class="button-primary align">Submit</button>
</div>
</form>
<p class = "align"> See how much you've spent on a type of clothing.</p>
<form onsubmit="runFuncTwo()">
<input class = "margin u-full-width" id="type" type = "text" placeholder="Enter clothing brand">
<div>
<button type="submit" class="button-primary align">Submit</button>
</div>
</form>
</body>
css:
h1{
font-size: 20pt;
width:100%;
}
h2{
font-size: 16pt;
width:100%;
}
html:add all text content within span tag:
<h1 class = "align "><span>Welcome to the clothing expense custom menu bar! </span></h1>

Line between divs

I want to draw a line between div, but can't figure out how to make <hr> take the length of the main div
Maybe there is some other solution?
I use react and semantic ui comments
create comment block:
const CommentWithReply: FunctionComponent<ICommentProps> = ({ author, createdAt, text, replies }) => (
<div className={styles.comment}>
<BasicComment createdAt={createdAt} text={text} author={author} />
<hr className={styles.hr}></hr>
<div className="comments">
{replies.map(e => (
<CommentWithReply
replies={e.comments}
author={e.author}
createdAt={e.createdAt}
text={e.text}
/>
))}
</div>
</div>
);
Basic comment
const BasicComment: FunctionComponent<IBasicCommentProps> = ({ createdAt, text, author }) => (
<div className={styles.commentInfo}>
<div className={styles.commentAuthor}>
<a href="/" className="avatar">
<img alt="avatar" src="https://i.imgur.com/LaWyPZF.png" />
</a>
<a href="/" className="author">
{author.lastName}
{' '}
{author.lastName}
</a>
<DividerSvg />
<div className="metadata">
<span className="date">{ moment(createdAt).fromNow() }</span>
</div>
</div>
<div className="content">
<div className="text">
{ text }
</div>
<div className="actions">
<DarkBorderButton className={styles.btnReplay} content="Reply" />
</div>
</div>
</div>
);
styles.scss
.comment {
margin-top: 1.25em;
border: 2px solid red;
box-sizing: border-box;
border-radius: 10px;
&:only-child {
&:last-child {
.hr {
visibility: visible;
display: flex;
width: 100%;
}
border: none;
}
}
&:last-child {
margin-bottom: -2em;
.hr {
display: none;
}
&:last-child {
}
}
}
main:
const CommentsFeed: FunctionComponent<ICommentProps> = ({ comments }) => (
<div className={styles.main}>
<p className={styles.commentCounter}> Discussion (58) </p>
<form className="ui reply form">
<div className="field">
<textarea placeholder="Add to the discussion..." />
</div>
<DarkBorderButton className={styles.buttonSend} content="Send" />
</form>
<div className="ui comments">
<div className="comment">
{comments.map(comment => (
<CommentWithReply
createdAt={comment.createdAt}
text={comment.text}
author={comment.author}
replies={comment.comments}
/>
))}
</div>
</div>
</div>
);

Validation Message CSS alignment in ASP MVC

I am new to ASP MVC,CSS and html.
Here is what i want to do:
1. Right after an Editorfor("Type" filed in my example), i need a button to display all available options in the database. I have already achieved this by using JQuery UI autocomplete.
2. Validation on this required field. I need to display validation message below the editor box. My code is not working.
<div class="form-group">
#Html.LabelFor(model => model.Description, htmlAttributes: new { #class = "control-label col-md-2 required" })
<div class="col-md-10">
#Html.EditorFor(model => model.Description, new { htmlAttributes = new { #class = "form-control" } })
#Html.ValidationMessageFor(model => model.Description, "", new { #class = "text-danger" })
</div>
</div>
<div class="form-group">
#Html.LabelFor(model => model.TestType, htmlAttributes: new { #class = "control-label col-md-2 required" })
<div class="col-md-10">
#Html.EditorFor(model => model.TestType, new { htmlAttributes = new { #class = "form-control" } })
<button id="ShowAllType" class="ui-button ui-widget ui-corner-all" title="Show all existing test types">
<span class="ui-icon ui-icon-triangle-1-s"></span>
</button>
#Html.ValidationMessageFor(model => model.TestType, "", new { #class = "text-danger" })
</div>
</div>
Here is before post.
Here is after post.
As the picture shows, "Description" field is OK. I need help to fix the alignment on "Type" field to display same as Description field. Thanks in advance.
Add CSS and JS:
<link rel="stylesheet" href="//code.jquery.com/ui/1.11.4/themes/smoothness/jquery-ui.css">
<link rel="stylesheet" href="//code.jquery.com/ui/1.12.1/themes/base/jquery-ui.css">
<script src="~/Scripts/jquery-3.1.1.js"></script>
<script src="~/Scripts/jquery-ui-1.12.1.js"></script>
<style>
.ui-autocomplete-loading {
background: white url("../images/ui-anim_basic_16x16.gif") right center no-repeat;
}
.ui-autocomplete {
max-height: 300px;
overflow-y: auto;
/* prevent horizontal scrollbar */
overflow-x: hidden;
/* add padding to account for vertical scrollbar */
padding-right: 20px;
}
#ShowAllType {
position: absolute;
top: 0;
bottom: 0;
margin-left: -1px;
padding: 0;
}
#TestType {
position: relative;
display: inline-block;
}
.required:after
{
content: "*";
font-weight: bold;
color: red;
vertical-align:sub;
}
</style>
<script type="text/javascript">
$(document).ready(function () {
$("#TestType").autocomplete({
source: function (request, response) {
$.ajax({
//url: "/EndEffectors/AutoCompleteType",
url: "#Url.Action("AutoCompleteType", "EndEffectors")",
type: "GET",
dataType: "json",
data: { Prefix: request.term },
success: function (data) {
$("#TestType").removeClass("ui-autocomplete-loading");
response(data);
}
})
},
complete: function () {
$("#TestType").removeClass("ui-autocomplete-loading")
},
minLength: 0,
messages: {
noResults: "", results: ""
}
});
$("#ShowAllType").on("click", function () {
$("#TestType").autocomplete("search", "");
return false;
});
}
)
</script>
<script src="#Url.Content("~/Scripts/jquery.validate.min.js")" type="text/javascript"></script>
<script src="#Url.Content("~/Scripts/jquery.validate.unobtrusive.min.js")" type="text/javascript"></script>
Edit 2: I tried add <br/> after the button, here is the result. Button size is not right.