0

Using following css code I can disable vertical scroll bar for whole mvc 4 project view files.

body {
 overflow-y: hidden!important;
}

But how to disable vertical scrollbar for specific cshtml view page

Chathz
  • 723
  • 4
  • 16
  • 41
  • Mode the CSS inside those specific views. If you target specific scenarios, you could add the text using Razor syntax. If you target specific HTML objects, set their ids or classes as selector instead of `body`. – Andrei V May 06 '15 at 06:45
  • can you explain more – Chathz May 06 '15 at 06:46
  • You can use specific selectors pertaining to those views rather than using the body selector. – Kurenai Kunai May 06 '15 at 06:47
  • @AndreiV can you give exmple – Chathz May 06 '15 at 06:48
  • Check out [this example](http://stackoverflow.com/questions/5021552/how-to-reference-a-css-file-on-a-razor-view) and also [this one](http://stackoverflow.com/questions/5110028/add-css-or-js-files-to-layout-head-from-views-or-partial-views). – Andrei V May 06 '15 at 06:49

1 Answers1

1

you have two main solutons: with CSS, you select one body or div with class selector ( see selector class for more informations), or you use JQUERY/JS

First solution : tou can wrap the razor page with

<div class="hideVerticalScrollbar">
content here
</div>

or directly use this body:

<body class="hideVerticalScrollbar">
    content here
</body >

and then use this rule:

.hideVerticalScrollbar{
 overflow-y: hidden!important;
}

OR second possibility, you can use jquery/javascript

$("body:has(div.hideVerticalScrollbar)").css( "overflow-y: hidden!important;" );
clement
  • 4,204
  • 10
  • 65
  • 133